與JSF

2011-06-09 34 views
0

我使用JSF有麻煩自動填充表單數據,我想自動填充表單數據爲我的形式,我想輸入不同的數據集(取決於用戶登錄) 例如:與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> 

和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"; 
     } 

    } 


.... 

任何幫助非常讚賞。

+0

什麼問題?我沒看到一個。 – TrueDub 2011-06-09 09:29:29

+0

您的selectItems標籤的'value'屬性引用'fCustomerAccounts',但這裏不存在。 – 2011-06-09 11:31:54

+0

到maple_shaft,我修改了它 – 2011-06-10 01:16:13

回答

0

如果您想要預先填寫表單,請初始化構造函數中的值。

+0

thanhs,但我想輸入不同的數據集(取決於用戶登錄) – 2011-06-11 02:24:47

+0

在Seam中,您可以使Bean sessionscoped在用戶登錄後創建。 – arved 2011-07-12 09:17:50

+0

另一個選項是移動你的ifBlock給吸氣劑 – arved 2011-07-12 09:19:20