[英]Exclude field from a form in JSF
我有以下问题:让我们假设下面的代码:
...
<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"
将使其不可编辑且不可提交(即,值未提交给服务器)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.