我有以下问题:让我们假设以下代码:
...
<h:form id="..">
<table>
<table border="1">
<tr>
<td><h:outputText value="#{msg.prompt1}"/></td>
<td><h:inputText value="#{personBean.personData1}" />
<!-- This field must not participate in the form. There would be
other JSF form and tags here -->
<h:commandButton action="other_action_with_ajax"/>
</td>
</tr>
<tr>
<td><h:outputText value="#{msg.promp2}"/></td>
<td><h:inputText value="#{personBean.personData2}" /></td>
</tr>
<tr>
<td><h:outputText value="#{msg.msg}"/></td>
<td><h:commandButton action="greeting" value="#{msg.button_text}" /></td>
</tr>
</table>
</h:form>
...
我需要从表格(当前为平面 html)中的表单中排除一个字段,因为该字段是只读的,并且处理和处理方式与其他字段不同。它将是不属于该表的包装形式的其他形式的一部分。但该字段必须放置在该表中才能正确格式化。我不能把形式放在形式中。将两个表单放入一个表中而不将其拆分为两个包装在表单中的表的最佳方法是什么?
最佳答案
只需使用输入组件的 readonly
或 disabled
属性即可。
例如
<h:inputText value="#{bean.value}" disabled="#{!bean.editable}" />
设置readonly="true"
将使其不可编辑,但可提交。设置 disabled="true"
将使其不可编辑且不可提交(即值不会提交到服务器)。
关于java - 从 JSF 中的表单中排除字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7108410/