【发布时间】:2011-05-28 04:09:08
【问题描述】:
基于上一个问题How to get ID of calling component in the getter method?,我想请教您的另一个想法:
jsf 页面中有很多重复的代码,例如这些跨组件的示例(注意重复大小和 maxlength 属性):
<h:inputText label="#{msgs.userId}" id="UserId" value="#{userBean.userId}"
required="true"
size="#{variableConfigBean.getSize(component.id)}"
maxlength="#{variableConfigBean.getMaxLength(component.id)}"
/>
<h:inputSecret label="#{msgs.password}" id="Password" value="#{userBean.password}"
required="true"
size="#{variableConfigBean.getSize(component.id)}"
maxlength="#{variableConfigBean.getMaxLength(component.id)}"
/>
我在想:
- 为此使用复合组件 输入文本标签,
- 在该复合组件的实现部分中硬编码大小和最大长度,
- 这样我就不必复制所有 每次我需要使用这些东西 该组件。
- 但我必须打开 将界面中的所有属性 该复合组件的部分
这个想法可以吗,或者有其他更好的方法来解决这个问题?
【问题讨论】: