究竟是什么process
,并update
在PrimeFaces p:commandXxx
组件和execute
和render
的f:ajax
标签?
哪个在验证时有效?什么是update
属性做,而不是更新的值从后端组件?不要process
属性绑定值模型?究竟是什么@this
,@parent
,@all
并@form
在这两个属性?
下面的例子工作正常,但我对基本概念有点困惑.
<p:commandButton process="@parent"
update="@form"
action="#{bean.submit}"
value="Submit" />
Run Code Online (Sandbox Code Playgroud) 最小示例对话框:
<p:dialog header="Test Dialog"
widgetVar="testDialog">
<h:form>
<p:inputText value="#{mbean.someValue}"/>
<p:commandButton value="Save"
onsuccess="testDialog.hide()"
actionListener="#{mbean.saveMethod}"/>
</h:form>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
我想要做的是让mbean.saveMethod以某种方式阻止对话框关闭,如果有问题并且只通过growl输出消息.这是验证器无法帮助的情况,因为在将保存提交给后端服务器之前无法判断someValue是否有效.目前我使用visible属性执行此操作,并将其指向mbean中的布尔字段.这有效,但它使用户界面变慢,因为弹出或关闭对话框需要命中服务器.
我已经开始学习JSF,但遗憾的是,大多数教程只提供登录或注册部分.
你能指点我一些更深入的例子吗?我感兴趣的一件事是一个展示产品清单的页面.我在页面回家,我按下页面产品,以便我可以看到添加的最新产品.每次访问该页面时,都会根据数据库中的最新条目创建产品列表.我怎么处理这个?
解决此问题的一种方法是创建一个会话范围的托管bean,在其中我将通过其他托管bean更新不同的实体.我在一些教程中发现了这种方法,但它看起来很困难而且很笨拙.
哪个是解决这类问题的最佳方法?在两页主从细节用户界面中,会话范围的正确用法是什么?
我在我的项目中使用PrimeFaces 3.2.我想知道设置a的渲染属性<p:dialog>
与设置visible属性之间的区别.我应该何时使用这些属性中的任何一个?
我有一个包含2个必填输入字段的表单和一个显示对话框的命令按钮:
<p:commandButton id="showDialogButton" value="Enregistrer"
action="#{DEQbean.Ajouter()}" update="@form"
oncomplete="dialogaboutDEQ.show()" />
<p:dialog id="reamrquesDEQ" widgetVar="dialogaboutDEQ" header="Informations"
width="400" closable="false" resizable="false" showEffect="clip"
hideEffect="clip" modal="true" appendToBody="true">
<p:messages id="messages" showDetail="true" autoUpdate="true"/>
<p:commandButton value="OK" action="DEQlist" />
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
我想仅在验证通过并执行action方法时才显示对话框.但是,当所需的输入字段为空并且因此未执行操作方法时,仍会显示该对话框.
如何在完成成功的表单提交后才显示对话框?
我有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) 我正在尝试创建一个对话框,用于创建对象和更新对象.因此,如果我碰巧点击"新建"按钮,我将看到一个包含要填充的空字段的对话框,或者如果我单击某个条目的编辑按钮,该条目的数据将显示在对话框中以进行更新.
按照版本5.2的primefaces展示中的示例,我可以以只读的outputText形式呈现数据,但是当我将其更改为inputText时,该字段保持为空.以下代码是我的例子:
<h:form id="form">
<p:dataGrid id="guestList" var="guest" value="${guestList.guests}" columns="3" paginator="true" rows="20">
<f:facet name="header">
Guest List
</f:facet>
<p:panel>
<h:outputText value="${guest.name}" />
<br />
<h:outputText value="${guest.street}" />
<br />
<h:outputText rendered="#{guest.street2.length() gt 0}"
value="${guest.street2}" />
<h:panelGroup rendered="#{guest.street2.length() gt 0}">
<br />
</h:panelGroup>
<h:outputText value="${guest.city}, " />
<h:outputText value="${guest.state} " />
<h:outputText value="${guest.zipCode}" />
<p:commandButton update="@form:newGuestDetail" oncomplete="PF('newGuestDialog').show()" icon="ui-icon-edit" styleClass="ui-btn-inline">
<h:outputText styleClass="ui-icon ui-icon-edit" style="margin:0 auto;" />
<f:setPropertyActionListener value="#{guest}" target="#{guestList.selectedGuest}" />
</p:commandButton>
</p:panel>
</p:dataGrid>
<p:dialog header="#{guestList.hasSelected() ? 'Edit Guest' : 'New Guest'}" widgetVar="newGuestDialog" modal="true" showEffect="fade" …
Run Code Online (Sandbox Code Playgroud) 这是我正在编写的一些 html,允许使用对话框添加类别:
<p:dialog id="newCategoryDlg" header="Add New Category" widgetVar="newCategoryDialog" resizable="false">
<h:form id="newCategoryForm">
<p:panelGrid id="displayNewCategory" columns="2" cellpadding="4" style="margin:0 auto;">
<h:outputText value="Category Name :"></h:outputText>
<p:inputText value="#{categoryController.newCategory.name}"
required="true" requiredMessage="Please Enter a Category ID!" />
<f:facet name="footer">
<p:commandButton value="Submit" update=":form:categoryTable"
oncomplete="newCategoryDialog.hide();"
actionListener="#{categoryController.addCategory}">
<p:resetInput target="displayNewCategory" />
</p:commandButton>
<p:commandButton type="reset" value="Reset"></p:commandButton>
</f:facet>
</p:panelGrid>
</h:form>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
现在,无论出于何种原因,无论我使用哪个小部件或标识符,“”似乎都不起作用。我想要的只是旧的输入条目在提交后消失。我究竟做错了什么?
jsf ×8
primefaces ×7
dialog ×5
validation ×2
ajax ×1
process ×1
reset ×1
scope ×1
session ×1
updates ×1