下面的代码是从PrimeFaces的DataGrid + DataTable的教程启发和放入<p:tab>一个的<p:tabView>居住在<p:layoutUnit>的<p:layout>.这是代码的内部部分(从p:tab组件开始); 外部是微不足道的.
<p:tabView id="tabs">
<p:tab id="search" title="Search">
<h:form id="insTable">
<p:dataTable id="table" var="lndInstrument" value="#{instrumentBean.instruments}">
<p:column>
<p:commandLink id="select" update="insTable:display" oncomplete="dlg.show()">
<f:setPropertyActionListener value="#{lndInstrument}"
target="#{instrumentBean.selectedInstrument}" />
<h:outputText value="#{lndInstrument.name}" />
</p:commandLink>
</p:column>
</p:dataTable>
<p:dialog id="dlg" modal="true" widgetVar="dlg">
<h:panelGrid id="display">
<h:outputText value="Name:" />
<h:outputText value="#{instrumentBean.selectedInstrument.name}" />
</h:panelGrid>
</p:dialog>
</h:form>
</p:tab>
</p:tabView>
Run Code Online (Sandbox Code Playgroud)
当我单击时<p:commandLink>,代码停止工作并给出消息:
找不到表达式为"insTable:display"的组件,引用自"tabs:insTable:select".
当我尝试相同的使用时<f:ajax>,它失败了,基本上告诉相同的不同消息:
<f:ajax>包含一个未知的id"insTable:display"无法在组件"tabs:insTable:select"的上下文中找到它
这是怎么造成的,我该如何解决?
我正在使用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.
谢谢
我如何在JSF 2.0中使用EL中的参数/变量/参数调用直接方法或方法?
例如,在EL中获取列表大小:
<h:outputText value="#{bean.list.size()}" />
Run Code Online (Sandbox Code Playgroud)
或者使用参数调用action方法:
<h:commandButton value="edit" action="#{bean.edit(item)}" />
Run Code Online (Sandbox Code Playgroud)
这在我的环境中似乎不起作用.它似乎不喜欢括号.
javax.el.ELException:错误解析:#{bean.list.size()}
com.sun.el.parser.ParseException:遇到"("
我有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)