java - 从 JSF 中的表单中排除字段

标签 java html 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)中的表单中排除一个字段,因为该字段是只读的,并且处理和处理方式与其他字段不同。它将是不属于该表的包装形式的其他形式的一部分。但该字段必须放置在该表中才能正确格式化。我不能把形式放在形式中。将两个表单放入一个表中而不将其拆分为两个包装在表单中的表的最佳方法是什么?

最佳答案

只需使用输入组件的 readonlydisabled 属性即可。

例如

<h:inputText value="#{bean.value}" disabled="#{!bean.editable}" />

设置readonly="true"将使其不可编辑,但可提交。设置 disabled="true" 将使其不可编辑不可提交(即值不会提交到服务器)。

关于java - 从 JSF 中的表单中排除字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7108410/

相关文章:

javascript - 如何使用 javascript 输入 window.prompt() 的值?

javascript - 如何将第 n 到第 n 个元素包装在 div 中

jsf - 使用对象参数指定方法签名

jsf - javax.el.PropertyNotFoundException : Target Unreachable, 'BracketSuffix' 返回 null

java - Pdf 查看器保存页面问题

java - 在不使用工作空间的情况下获取变更集中文件的路径

java - 什么是 SuppressLint Java 注释?

javascript - 更改嵌套在另一个 HTML 项目中的项目的 innerHTML

ajax - 类路径中的 ICEfaces 库可防止文件下载时弹出“另存为”对话框

java - 获取数组长度时出错抛出异常