我对数据表选择有一些奇怪的问题(很可能我做错了什么)。想法很简单 - 带有选择的数据表和编辑记录的对话框。问题是,如果我使用<h:inputText>
标签(或<p:inputText>
)它似乎是空白的,尽管支持 bean(indicatorBean.indicator.code
)中的对象包含数据。有趣的是,如果我<h:outputText>
输入而不是输入,则会显示数据。
这是我身体的内容
<!-- language: xml -->
<h:body>
<h:form id="form">
<p:growl id="messages" showDetail="true"/>
<p:dataTable id="indicatorsTable" var="ind"
value="#{indicatorBean.indicators}"
selectionMode="single"
selection="#{indicatorBean.indicator}"
rowKey="#{ind.id}">
<p:column headerText="Name" style="width:125px">
#{ind.name}
</p:column>
<p:column headerText="Code" style="width:125px">
#{ind.code}
</p:column>
<f:facet name="footer">
<p:commandButton id="viewButton" value="View"
icon="ui-icon-search" update=":form:display"
oncomplete="indDialog.show()"/>
</f:facet>
</p:dataTable>
<p:dialog id="dialog" header="Indicator Detail"
widgetVar="indDialog" resizable="false"
width="400" showEffect="fade" hideEffect="fade">
<h:panelGrid id="display" columns="2" cellpadding="4">
<h:outputText value="Code:"/>
<!-- PROBLEM IS HERE -->
<h:inputText value="#{indicatorBean.indicator.code}"/>
<h:outputText value="Name:"/>
<h:outputText value="#{indicatorBean.indicator.name}"/>
</h:panelGrid>
<p:commandButton value="Save" onclick="indDialog.hide()"/>
<p:commandButton value="Cancel" onclick="indDialog.hide()"/>
</p:dialog>
</h:form>
</h:body>
支持 bean 就是访问器。
我发现的另一件事是,如果我用<h:inputtext>
静态文本(如<h:inputText value="static text"/>
)替换 el 表达式,它就会显示出来。以下是一些图片:
带有输入文本的对话框
带有输出文本的对话框
带有静态文本的对话框
素面3.4