开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜