我想在我的*.xhtml页面上放一个打包游戏.(我使用的是jsf 2和primefaces 3.5)
然而,
当我在xhtml中"翻译"html页面时,我在此脚本中收到错误:
<script>
var el = document.getElementById("pacman");
if (Modernizr.canvas && Modernizr.localstorage &&
Modernizr.audio && (Modernizr.audio.ogg || Modernizr.audio.mp3)) {
window.setTimeout(function () { PACMAN.init(el, "./"); }, 0);
} else {
el.innerHTML = "Sorry, needs a decent browser<br /><small>" +
"(firefox 3.6+, Chrome 4+, Opera 10+ and Safari 4+)</small>";
}
</script>
Run Code Online (Sandbox Code Playgroud)
在线:
if (Modernizr.canvas && Modernizr.localstorage &&
Run Code Online (Sandbox Code Playgroud)
我得到:
实体名称必须紧跟实体引用中的"&".
知道怎么解决这个问题吗?
我有一个包含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方法时才显示对话框.但是,当所需的输入字段为空并且因此未执行操作方法时,仍会显示该对话框.
如何在完成成功的表单提交后才显示对话框?
我有一个CRUD页面,显示Primefaces数据表中查询(域对象列表)的数据.
<p:dataTable
id="negozi"
var="n"
value="#{nController.theListFromQuery}"
rowKey="#{n.id}"
selection="#{nController.selected}"
selectionMode="single">
<p:column headerText="Field1">
<h:outputText value="#{n.f1}" />
</p:column>
<p:column headerText="Field2">
<h:outputText value="#{n.f2}" />
</p:column>
<p:column style="width:4%">
<p:commandButton
actionListener="#{nController.prepareEdit(n)}"
update=":editDialogId"
oncomplete="editDialog.show()"
value="Edit" />
</p:column>
...
Run Code Online (Sandbox Code Playgroud)
通过单击编辑按钮,将显示一个对话框:
<p:dialog
header="Edit N"
widgetVar="editDialog"
id="editDialogId">
<h:form id="formDialog">
<h:panelGrid id="editDialogTable" columns="2" cellpadding="10" style="margin:0 auto;">
<p:outputLabel for="field1" value="F1:" />
<p:inputText id="field1" value="#{nController.selected.f1}" />
<p:outputLabel for="field2" value="F2:" />
<p:inputText id="field2" value="#{nController.selected.f2}" />
<p:commandButton
value="Confirm"
actionListener="#{nController.doEdit}"
update=":form"
oncomplete="editDialog.hide()"
rendered="#{nController.selected.id!=null}" />
...
Run Code Online (Sandbox Code Playgroud)
有用.现在我想让F1成为必填项目.
我将"required"属性添加到inputText字段,会发生什么?
当我尝试确认没有必填字段的表单时,实体不会被编辑(这是正确的),但对话框已关闭(这不对!)
当我重新打开对话框时,我可以在所需(和无效)字段上看到红色突出显示.
我想要的是在表单无效时阻止对话关闭.
我是否必须编写一些JS或者JSF会帮助我吗?
我有一个JSF 2应用程序,它有两个页面,一个用于列出学生,另一个用于显示给定学生的详细信息.列表页面包含指向学生表每行中详细信息页面的链接,该页面在浏览器中打开一个新选项卡,以便在单击时显示这些详细信息.
现在,需求已更改为在新选项卡中显示详细信息,但在列表页面中的模式对话框中.
我的想法是简单地将详细信息页面内容嵌入到模态对话框中,这样列表页面就不会太大而且难以维护.在这里开始我的怀疑.经过一番研究后,我将列表每行中的链接更改为以下按钮:
<p:commandButton value="Details" type="button"
onclick="PF('dialog-details').show()">
</p:commandButton>
Run Code Online (Sandbox Code Playgroud)
该对话框声明如下:
<p:dialog widgetVar="dialog-details" header="Details" modal="true" width="95%">
<ui:include src="student_details.xhtml">
<ui:param name="id" value="#{student.id}"/>
</ui:include>
</p:dialog>
Run Code Online (Sandbox Code Playgroud)
最后,详细信息页面更改为如下所示:
<ui:composition
xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:metadata>
<f:viewParam name="id" value="#{studentBean.id}" />
</f:metadata>
<h1 class="title ui-widget-header ui-corner-all">Details of #{studentBean.bean.name} / #{studentBean.bean.number}</h1>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
当我单击按钮时,对话框确实显示,内容是详细信息页面.我在对话框中看到以下内容:
Details of /
Run Code Online (Sandbox Code Playgroud)
根本没有错误,但应该显示的数据不是.设置了断点StudentBean.setId()(此方法加载以bean与Student传递的id对应的实例命名的属性),但它永远不会被命中.
经过一段时间的思考,我才明白为什么它不起作用.传递给详细信息页面的参数是student.id,但是在显示所有学生时student使用的名称,因此无效在其中.var<p:datatable/>student<p:dialog/><p:datatable/>
所以,我需要的是一种使用给定行中相应学生的id来显示对话框的方法.理想情况下,我想在这里进行ajax调用,因此细节只有在被绑定时才会加载.
有任何想法吗?
我正在使用<p:dialog>. 在其中提交表单后,我使用dialog.hide()并触发 ajax close 事件侦听器方法,该方法将更新List<E>. 它工作正常,但是当我放置一些必需的输入组件并在<p:dialog>出现验证错误时再次调用时,它不再触发该方法。
对话框:
<p:outputPanel autoUpdate="true">
<p:dialog id="dialogComentario" header="Deixe sua avaliação" widgetVar="confirmation"
showEffect="fade" hideEffect="fade" height="340" width="500" modal="true"
visible="#{not empty facesContext.maximumSeverity}"
resizable="false" closable="true" draggable="false">
<h:form prependId="false">
...
<p:commandLink styleClass="btn btn-primary btenviacoment"
oncomplete="if (!args.validationFailed) confirmation.hide();"
actionListener="#{comentario.actEnviarComentario}" global="false">
<i class=" icon-play-circle icon-white"></i>
<h:outputText value=" Enviar Comentário" />
<f:param name="codigoplu" value="#{produto.produto.codigoplu}" />
</p:commandLink>
...
<p:commandLink styleClass="btn" onclick="confirmation.hide();"
global="false" immediate="true">
<h:outputText value=" Cancelar" />
<i class="icon-off"></i>
</p:commandLink>
...
</h:form>
<p:ajax event="close" update=":avaliacoesClientes, :dialogComment"
listener="#{produto.atualizarComentarios}" …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) 我正在使用 jsf 2。我的代码的一部分是这样的:
<h:panelGrid id="jobDetail" columns="3" cellpadding="7">
<p:outputLabel value="#{msg['content.jobList.JobName']}" />
<p:inputText id="jobName" styleClass="BIC_search_textbox" value="#{timerConfigurationBean.selectedTimerConfigurationJob.jobName}" required="true" requiredMessage="#{msg['content.jobNew.requiredfield.errormsg']}"/>
<p:message for="jobName" styleClass="error"/>
</h:panelGrid>
<p:commandButton id="update" value="Update_Button" action="#{timerConfigurationBean.updateExportJob}" styleClass="bottomButtonsAfterFirst" update="jobDetail" oncomplete="PF('updatejobpopup').show()"/>
Run Code Online (Sandbox Code Playgroud)
这只是代码的一部分。发生的情况是,当我单击命令按钮“Update_Button”时,会发生以下两件事之一:
1)我在 inputText“jobName”中输入一个值,然后单击命令按钮。首先,action="#{timerConfigurationBean.updateExportJob}" 中的函数运行,然后 oncomplete="PF('updatejobpopup').show()" 运行。这就是它的初衷,所以没关系。
2)我没有在输入文本中输入任何内容(这是必填字段),然后单击命令按钮。我在 Inputtext 字段旁边的网页上看到一条错误消息(发生这种情况是因为我的 commandButton 中有 update="jobDetail")并且 action="#{timerConfigurationBean.updateExportJob}" 未运行,但 oncomplete="PF(' updatejobpopup').show()" 仍然运行。这是个问题。
我希望 oncomplete 仅在页面上没有错误时运行,就像 action="#{timerConfigurationBean.updateExportJob}" 中的函数一样。
有人可以帮忙吗?
jsf ×7
primefaces ×5
dialog ×4
validation ×3
javascript ×2
jsf-2 ×2
ajax ×1
datatable ×1
facelets ×1
html ×1
java ×1
xhtml ×1
xml ×1