Autofill form data with jsf
I am having trouble using JSF, I want to auto fill form data for my form and I want to input different data sets (depending on user login) for example:
view :
<h:form id="ftextform">
<div class="region">
<s:decorate template="/pr/layout/edit.xhtml">
<ui:define name="label">Account</ui:define>
开发者_Go百科<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>
and the bean
@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";
}
}
....
Any help much appreciated.
Initialize the values in the Constructor, if you want the form prefilled.
精彩评论