我想编写一个代码来获取素面日历输入值的输入值。
<div style="padding-left: 300px;">
<p:calendar value="#{calendarBean.fromDate}" id="fromButton" showOn="button" pattern="dd-MMMM-yyyy"
required="true" requiredMessage="Insert From Date!">
</p:calendar>
<p:calendar value="#{calendarBean.toDate}" id="toButton" showOn="button" pattern="dd-MMMM-yyyy"
style="padding-left: 100px;padding-right: 30px" required="true" requiredMessage="Insert To Date!">
</p:calendar>
<p:commandButton actionListener="#{userLeaveBean.addAppliedLeave}" styleClass="apply_button" value="Create Leave">
<f:attribute name="userId" value="#{employee.name}"/>
</p:commandButton>
</div>
我想通过方法调用传递三个参数值(userId,fromDate,toDate)
<p:commandButton actionListener="#{userLeaveBean.addAppliedLeave}" styleClass="apply_button" value="Create Leave">
使用方法 addAppliedLeave()。我可以使用以下方式发送 userId:
<f:attribute name="userId" value="#{employee.name}"/> but how can I pass the values for calender input at run time?
我也可以在方法 addAppliedLeave() 中获取 userId 的值
public void addAppliedLeave(ActionEvent event){
String userId = (String)event.getComponent().getAttributes().get("userId");
System.out.println(userId);
String fromDate = (String)event.getComponent().getAttributes().get("fromDate");
System.out.println(fromDate);
}
但我对<p:calendar>
价值的动态输入完全无能为力。请帮忙。