问题描述
我有以下问题:让我们假设下面的代码:
...
< table>
< table border =1>
< tr>
< td>< h:outputText value =#{msg.prompt1}/>< / td>
< td>< h:inputText value =#{personBean.personData1}/>
其他的JSF表单和标签 - >
< 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 =greetingvalue =#{msg.button_text}/>< / td>
< / tr>
< / table>
< / h:表格>
...
我需要从表格中排除一个字段(目前是平面html),因为该字段是只读的,并且与其他字段处理和处理方式不同。这将是其他形式的一部分,而不是本表的包装形式。但是这个字段必须放置在这张表格中才能正确地形成。我不能将表格放在一个表格中。将两个表单放在一个表中而不将它分成两个表格的最好方法是什么?
输入组件的 readonly
或 disabled
属性。 例如
< h:inputText value =#{bean.value}disabled = #{!bean.editable}/>
设定 readonly =true
会令它不可编辑,但可以提交。设置 disabled =true
将使其不可提交和不可提交(即,价值未提交给服务器)。
I have the following question: Let's assume the code below:
...
<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>
...
I need to exclude one field from a form which is in a table (currently plane html) as this field is readonly and handled and treated differently from the others. It will be part of other form which does not the wrapping form of this table. But this field must be placed in this table to be formated correctly. And I cant put form in a form. What is the best way to put two forms in one table without splitting it into two tables wrapped in forms?
Just make use of the input component's readonly
or disabled
attribute.
E.g.
<h:inputText value="#{bean.value}" disabled="#{!bean.editable}" />
Setting readonly="true"
will make it uneditable, but submittable. Setting disabled="true"
will make it uneditable and unsubmittable (i.e. value isn't submitted to server).
这篇关于从JSF中的表单中排除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!