【问题标题】:Enable/disable panel on click of button in jsf/primefaces?单击jsf / primefaces中的按钮启用/禁用面板?
【发布时间】:2014-02-20 07:09:01
【问题描述】:

我有一个名为 Add oncilck 的按钮需要显示添加面板,并且在面板内有一个取消按钮 onclick 取消面板应该关闭我的问题是 onclicking 添加按钮面板即将出现并消失.实际上我已经包含了 template_2.xhtml ,它有..如果我从 template_2.xhtml 中删除,面板工作正常,但这些警告是这样来的 表单组件需要在其祖先中有一个 UIForm。建议:将必要的组件包含在我希望两者都能正常工作并且不应该出现警告的情况下。这是我的代码i know the problem that i am using 2 times form in 1 xhtml page but not able to overcome that help me out `

     <h:commandButton value="Add" id="show"  action="#"  onclick="panelwv.show()" ></h:commandButton>
    <h:form>

        <p:panel id="panel" widgetVar="panelwv" visible="false"  header="Add Dependents">
             <h:panelGrid id="myPanel" columns="3" cellpadding="5" styleClass="text-input">


            <h:outputText value=""/>

              <h:outputLabel  value="Name" style="font-family: cursive;font-size: 18px;font-weight:normal;"/>  
              <h:inputText  id="name"  value="#{depco.depapp.dep.name}" styleClass="border" label="First Name" />
               <h:outputText value=""/>

              <h:outputLabel  value="Relationship" style="font-family: cursive;font-size: 18px;font-weight:normal;"/>  
              <h:inputText id="rel"  value="#{depco.depapp.dep.relationship}" styleClass="border" label="Relationship" />
               <h:outputText value=""/>



               <h:outputLabel  value="Date of Birth" style="font-family: cursive;font-size: 18px;font-weight:normal;"/>  
               <p:calendar id="dob"  value="#{depco.depapp.dep.dob}" showOn="button"  label="Date of Birth" />
               <h:outputText value=""/>


             <h:outputLabel value="Emp Id" />
             <h:selectOneMenu value="#{depco.depapp.dep.empId}"  > &nbsp;
                 <f:selectItems value="#{coemp.empapp.itemsAvailableSelectOne}"  var="emp" itemLabel="#{emp.empId}" itemValue="#{emp.empId}" />
                 <f:converter converterId="employeeConverter" />
             </h:selectOneMenu> 
               <h:outputText value=""/>


               <h:commandButton value="Save" action="#{depco.createDepAction()}"/>
                <h:commandButton action="#" id="hide" onclick="panelwv.hide()" value="cancel"/> 


             </h:panelGrid>
                 </p:panel> 
    </h:form>
    `

【问题讨论】:

    标签: javascript jquery jsf jsf-2 primefaces


    【解决方案1】:

    您的示例对我来说很好用,[使用 Primefaces 3.5 JSF 2.1.13]。
    可能是您使用的按钮有问题。

    通常h:commandButton 不会进行 Ajax 提交,它会提交表单,直到您明确指定 f:ajax,所以这可能是面板出现和消失的原因。

    使用p:commandButton,默认情况下执行ajax提交。或者使用f:ajax和h:commandButton。

    由于您没有从您的h:commandButtons 调用任何 ManagedBean 的属性或方法,您甚至可以使用h:button。

    【讨论】:

    • :如果我在
      ....中包含 ...,我已经包含了名为 template_2.xhtml 的 jsf 页面: form>这个错误来了,面板正在显示。我尝试使用 p:commandButton 出现同样的问题,你能帮我举个例子吗
    【解决方案2】:

    JSF 菜单和子菜单标签应该包含在表单标签中。所以我只是用一些名称(比如 xyz.xhtml)创建一个单独的 jsf 文件,我只是使用

    在实际的 jsf 页面中包含 xyz.xhtml

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-03
      • 2019-05-24
      • 2014-01-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多