0

我正在创建一个网页。内容应根据用户选择而改变。

我需要 2 个单选按钮,可以选择一天和多天(开始日期和结束日期)如果一天选择的页面应该显示一个日历来选择日期,否则两个日历来选择开始日期和结束日期我尝试使用渲染ajax 的属性,但我无法查看日历我怎么能这样做

我的 xhtml

<h:form id="f1">
                    <p:growl id="createmsg"/>  
                    <h:panelGrid columns="2" cellpadding="10">
                        <p:panel id="add_visitor_details_pnl" style="width:100%"> 
                            <h:panelGrid id="grid" columns="2" cellpadding="10">
                                <h:outputText value="Organization :" />
                                <p:selectOneMenu  editable="true" value="#{visitorBean.organization}"  style="width:160px"  filter="true" filterMatchMode="startsWith">
                                    <f:selectItems value="#{visitorBean.organizations}" />
                                </p:selectOneMenu>
                                <h:outputText value="Visitor Name :" />
                                <p:selectOneMenu value="#{visitorBean.name}"  style="width:160px"  filter="true" filterMatchMode="startsWith">
                                    <f:selectItems value="#{visitorBean.names}" />
                                </p:selectOneMenu>
                                <h:outputText value="Visitor ID :" />
                                <p:selectOneMenu value="#{visitorBean.id}"  style="width:160px"  filter="true" filterMatchMode="startsWith">
                                    <f:selectItems value="#{visitorBean.ids}" />
                                </p:selectOneMenu>                                                         
                                <h:outputText value="Purpose :" />
                                <p:inputTextarea id="purpose_it" value="#{visitorBean.purpose}" required="true" autoResize="false"
                                             requiredMessage="Enter Purpose" rows="10" cols="50"/>
                            </h:panelGrid>
                            <h:panelGrid columns="1" cellpadding="10">
                                <p:selectOneRadio id="customRadio" value="#{visitorBean.option}" >  
                                    <f:selectItem itemLabel="Create a one day appointment" itemValue="1" />  
                                    <f:selectItem itemLabel="create a day period appointment" itemValue="2" />
                                    <p:ajax event="change" listener="#{visitorBean.selectDayType()}" 
                                            update=":f1:add_visitor_details_pnl"     />
                                </p:selectOneRadio>
                            </h:panelGrid>
                            <h:panelGrid id="date" columns="3" cellpadding="10">
                                <h:outputText id="date1" value="Date" rendered="#{visitorBean.cal1}"/> 
                                <p:calendar id="calender_Cal1" value="#{visitorBean.date_time}" 
                                            pattern="yyyy-MM-dd"  rendered="#{visitorBean.cal1}" 
                                            required="true" requiredMessage="Enter Date Time"/>
                                <p:calendar id="calender_Cal2" value="#{visitorBean.date_time}" 
                                            pattern="yyyy-MM-dd"  rendered="#{visitorBean.cal2}" 
                                            required="true" requiredMessage="Enter Date Time"/>
                            </h:panelGrid>
                            <h:panelGrid columns="2" cellpadding="10">
                                <p:commandButton id="submit_visitor_Btn" value="Create"                                                         
                                                 action="#{visitorBean.submitVisitorData()}"
                                                 update=":f1:visitor_dataTable,:f1:grid,:f1:createmsg"/>



                            </h:panelGrid> 

我的ajax方法

public void selectDayType(){
    if(option =="1")
        cal1 = "true";
    else if(option =="2"){
        cal1="true";
        cal2="true";            
    }
4

1 回答 1

0

尝试在日历周围加上:

<p:outputPanel  id="someId" >
...
</p:outputPanel>

Primefaces - 输出面板

于 2013-07-02T07:39:06.610 回答