我在使用JSF时遇到问题,我想自动填写表单的表单数据,我想输入不同的数据集(取决于用户登录) 例如:
观点:
<h:form id="ftextform">
<div class="region">
<s:decorate template="/pr/layout/edit.xhtml">
<ui:define name="label">Account</ui:define>
<h:inputText id="account" value="#{fundTranferExt.account}" required="true" />
</s:decorate>
<s:decorate template="/pr/layout/edit.xhtml">
<ui:define name="label">Amount</ui:define>
<h:inputText id="amount" value="#{fundTranferExt.amount}" required="true" />
</s:decorate>
</div>
<h:commandButton id="test" value="test" action="#{fundTranferExt.setSomething}"/>
</h:form>
和豆
@Name("fundTranferExt")
public class FundTranferExt implements IFundTranferExt
{
String account;
int amount;
public void setSomething()
{
// This code will not effect to view(xhtml) after executed
if(username="A"){
this.amount = 10000;
this.account= "123456";
}
else{
this.amount = 20000;
this.account= "24689";
}
}
....
任何帮助都非常感激。
答案 0 :(得分:0)
如果希望预填充表单,请在构造函数中初始化值。