在带有 Primefaces 的 xhtml 页面中,我想显示一个带有 FontAwesome 图标(fa-check)的勾号图标。由于可以将图标属性添加到例如 primefaces 按钮或 primefaces commandButton,我使用带有图标属性的 commandButton。我的问题是,如果我使用 f:ajax 渲染从另一个元素中引用它,则会出现错误:
malformedXML:更新期间 formId:tickIcon 未找到
我知道已经有这类问题了,但我没有解决这个问题。
以下是我的 xhtml 页面的相关部分:
<h:form id="formId" enctype="multipart/form-data">
<p:wizard>
<p:tab id="tab1">
...
</p:tab>
<p:tab id="tab2">
<p:panel>
<p:panelGrid styleClass="ui-panelgrid-blank">
<p:row>
<p:column colspan="2">
<p:outputLabel id="wrapperLabel" value="Select a file"
styleClass="wrapperLabel">
<h:inputFile id="fileUpload" styleClass="fileUploadButton"
value="#{bean.file}" required="true">
<f:ajax listener="#{bean.tempUpload()}"
render="showFileName createButton tickIcon" />
</h:inputFile>
</p:outputLabel>
</p:column>
<p:column colspan="1">
<p:outputLabel value="Filename: " />
</p:column>
<p:column colspan="5">
<p:inputText id="showFileName"
value="#{bean.fileName}" readonly="true" />
</p:column>
<p:column colspan="1">
<p:commandButton id="tickIcon" icon="fa fa-check"
disabled="true" styleClass="tickIcon"
rendered="#{bean.validFile}" />
</p:column>
</p:row>
</p:panelGrid>
</p:panel>
</p:tab>
</p:wizard>
</h:form>
更具体的是 h:inputFile 有一个 f:ajax,当文件上传完成时,它会刷新 inputText 字段和 2 个 commandButtons 的呈现。validFile 是一个布尔变量,文件上传后为真。但是通过带有图标的 commandButton 更新不起作用,而其他 2 则起作用。
如果有人对显示 Fontawesome 图标有更好的想法,也欢迎。
更新:
如果我以这种方式引用命令按钮,它“几乎”可以工作::tickIcon,所以通过 ajax 组件我写了这个:
<f:ajax listener="#{bean.tempUpload()}"
render="showFileName createButton :tickIcon" />
几乎,因为它只有在我返回向导中的上一个选项卡然后返回时才有效。组件一开始没有更新。
更新 2:
它现在可以工作了,我以这种方式更改了代码:
<f:ajax listener="#{bean.tempUpload()}"
render="@form" />
所以整个表格被更新了。