这是我与 JSF 合作的第二天。以前没有 Java 方面的背景,已经使用 Flex 和 C++ 有一段时间了。一些历史,让每个人都知道我来自哪里。对于“匆忙”项目,我遇到了问题
<h:panelGroup id="txeTab" layout="block" class="txeTab">
<h1>TXE</h1>
<h:form id="txeForm">
<h:panelGrid columns="3">
<c:forEach items="${txeConfBean.getListTable()}" var="property">
<h:outputLabel id="key" value="${property.key}"/>
<h:inputText id="value" value="${property.value}" />
<h:commandButton value="Change" action='${txeConfBean.setProperty('key','value')}'/>
</c:forEach>
</h:panelGrid>
</h:form>
</h:panelGroup>
和 Bean 如下
public HashMap <String,String> getListTable ()
{
String[] keys = new String[super.keyData.size()];
HashMap <String,String> retKeys = new HashMap <String, String>();
super.keyData.toArray(keys);
for (int i=0;i<keys.length;i++)
{
if(!keys[i].isEmpty())
{
retKeys.put(keys[i],getProperty(keys[i]));
}
}
return retKeys;
}
我能够递归地显示键值对。h:inputText id="value" value="${property.value}" />
但是一旦有人更新并按下新值写入的命令按钮,我想用新值更新特定键。在这方面需要帮助。谷歌搜索让我觉得有太多方法可以做到这一点。需要帮忙。我只是无法弄清楚要传递给什么${txeConfBean.setProperty('key','value')}
我如何将 InputText 和 OutPutText 的值传递给 setProperty ?