相关疑难解决方法(0)

如何在JSF页面中使用<h:form>?单一形式?多种形式?嵌套表格?

我正在使用Facelet模板技术在我正在处理的JSF 2应用程序中布局我的页面.

在我的header.xhtml中,primefaces要求菜单栏包含在h:form中.

<h:form>
    <p:menubar autoSubmenuDisplay="true">
        Menu Items here!
    </p:menubar>
</h:form>
Run Code Online (Sandbox Code Playgroud)

所以,在我的内容页面中,我将有另一个h:form或更多.

如果我只是将h:form放在我的template.xhtml中,它会起作用吗?

<h:body>
    <h:form>
        <div id="top">
            <ui:insert name="header"><ui:include src="sections/header.xhtml"/></ui:insert>
        </div>
        <div>
            <div id="left">
                <ui:insert name="sidebar"><ui:include src="sections/sidebar.xhtml"/></ui:insert>
            </div>
            <div id="content" class="left_content">
                <ui:insert name="content">Content</ui:insert>
            </div>
        </div>
        <div id="bottom">
            <ui:insert name="footer"><ui:include src="sections/footer.xhtml"/></ui:insert>
        </div>
    <h:form>
</h:body>
Run Code Online (Sandbox Code Playgroud)

我实际上正在考虑一个用例,我需要在页面中使用多个h:form.

谢谢

forms jsf nested jsf-2

44
推荐指数
1
解决办法
5万
查看次数

按PrimeFaces p:commandButton时事件的执行顺序

我试图执行一个JSF2 bean方法,并在完成单击PrimeFaces的方法后显示一个对话框<p:commandButton>.

<p:commandButton id="viewButton" value="View"
    actionlistener="#{userBean.setResultsForSelectedRow}" ajax="false"
    update=":selectedRowValues"
    oncomplete="PF('selectedRowValuesDlg').show()">
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)
<p:dialog id="selectedRowValues" widgetVar="selectedRowValuesDlg" dynamic="true">
    <h:outputText value="#{userBean.selectedGroupName}" />
</p:dialog>
Run Code Online (Sandbox Code Playgroud)

当我单击命令按钮时,bean动作侦听器方法setResultsForSelectedRow正确执行,但在方法完成时它不显示对话框.如果我删除actionlistener,它会显示对话框.我不知道出了什么问题.

事件的执行顺序是什么?是否有可能执行actionlisteneroncomplete同步?

jsf action primefaces jsf-2 commandbutton

33
推荐指数
2
解决办法
10万
查看次数

p:commandbutton action在p:dialog中不起作用

我有ap:对话框,里面有一个面板.问题是"保存"按钮的操作方法不起作用.它甚至不调用该方法.我可以达到方法def.使用ctrl + lm,因此方法名称没有问题.

<h:body>
    <h:form id="createAppUserForm" prependId="false">
      ....
      <p:dialog id="newRoleDialogId"
                  header="Add New Role"
                  resizable="true"
                  draggable="true"
                  widgetVar="newRoleDetailsDialog"  
                  appendToBody="true"
                  >
            <p:panel id="newRoleDialogPanel">
                <p:panelGrid id="newRoleDialogPanelGrid" columns="2" style="width: 100%" styleClass="panelGridWithoutBorder">
                    <h:outputText value="Role Name :"/>
                    <p:inputText value="#{createAppUserController.selectedRole.name}"/>
                    <h:outputText value="Role Desc :"/>
                    <p:inputText value="#{createAppUserController.selectedRole.description}"/>
                </p:panelGrid>
                <center>
                    <p:commandButton value="Save"
                                     update="roleListDataTable newRoleDialogPanelGrid growlCreateAppUser"
                                     oncomplete="if (!args.validationFailed) newRoleDetailsDialog.hide()"                                     
                                     action="#{createAppUserController.saveNewRole()}"/>
                    <p:commandButton value="Cancel"                                         
                                     immediate="true"
                                     onclick="newRoleDetailsDialog.hide()" />
                </center>
            </p:panel>
        </p:dialog>
       </h:form>
    </h:body>
Run Code Online (Sandbox Code Playgroud)

jsf dialog primefaces commandbutton

7
推荐指数
1
解决办法
2万
查看次数

p:messages 显示但几乎立即消失

我有一个关于 ap:message 标签的奇怪问题。在页面 a 上有一个包含来自我的数据库的数据的数据表,我可以在 ap:dialog 中进行编辑。一旦所有验证成功并且数据库中的更新完成,我刷新数据表并添加一个faces消息信息以显示操作的成功。在前端,我更新了包含 dataTable 和对话框的表单。我的问题是该消息已显示但几乎立即消失。这就像消息标签随着表单更新。我不明白。

我试图将消息标签移入和移出表单中没有任何改变。我试图调整 remoteCommand 以仅更新 dataTable 和对话框,但没有用。

<p:messages autoUpdate="true" showDetail="true" severity="info,error" />
<h:form id="form">
    <p:dataTable
    style="width: 80%; margin-left: auto; margin-right: auto; text-align:center"
        var="achievement" value="#{achievementBean.listAchievement}">
    ...
    </p:dataTable>

    <p:dialog header="#{i18n['achievement']}" widgetVar="dlg"
        dynamic="true" closable="false" resizable="false" showEffect="fade"
        hideEffect="fade">
        <h:panelGroup id="achievementDetail">
            <p:messages autoUpdate="true" severity="warn" />
            ...
            <h:panelGrid columns="2" style="width: 100%; text-align:center">
                <p:commandButton value="#{i18n['general.submit']}"
                    icon="fa fa-check"
                    actionListener="#{achievementBean.submitAchievement}"
                    oncomplete="if(!args.validationFailed){updateForm();}" />
                <p:commandButton value="#{i18n['general.cancel']}"
                    icon="fa fa-close" action="#{achievementBean.submitCancel}"
                    oncomplete="PF('dlg').hide();" update="@form" process="@this" />
            </h:panelGrid>
            <p:remoteCommand name="updateForm" update="@form" />
        </h:panelGroup>
    </p:dialog>
</h:form>
Run Code Online (Sandbox Code Playgroud)

jsf primefaces

3
推荐指数
1
解决办法
100
查看次数

标签 统计

jsf ×4

primefaces ×3

commandbutton ×2

jsf-2 ×2

action ×1

dialog ×1

forms ×1

nested ×1