2016-05-13 7 views
1

私はp:inputTextareaを持っており、フォームの処理中にその値が必要です。私がフォームを提出するたびに、私はテキストエリアからのもの以外のすべての値を取得することが判明しました。 #{xyzUI.description}は、通常のgetterとsetterを持つStringオブジェクトです。p:inputTextareaは空の文字列を返します

<ui:composition> 
    <h:form id="form1"> 
     <p:panel rendered="..."> 
      <p:panel id="formPanel"> 
       <p:panelGrid columns="2" cellpadding="5"> 
        <!-- other form elements --> 
        <p:outputLabel>Description:</p:outputLabel> 
        <p:inputTextarea value="#{xyzUI.description}" style="width: 350px;" counter="display" counterTemplate="{0} characters remaining" maxlength="2000" autoResize="true" rows="4" /> 
        <h:panelGroup /> 
        <h:outputText id="display" /> 
       </p:panelGrid> 
       <p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" ajax="true" value="Apply" > 
        <p:ajax update="formPanel"></p:ajax> 
       </p:commandButton> 
      </p:panel> 
     </p:panel> 
    </h:form> 
<ui:composition> 

私のバッキングビーンでは、値は常に ""です。私は何が間違っているのか分からない。

public void submitForm() 
{ 
    ... 
    tmp.setDescription(description); // String is always "" while debugging 
    myList.add(tmp); 
    RequestContext.getCurrentInstance().update("content"); 
} 
+0

のための私のバッキングBean

<p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" value="Apply" /> 

:これに

<p:commandButton rendered="#{not xyzUI.noChange}" action="#{xyzUI.submitForm}" update="formPanel" ajax="true" value="Apply" > <p:ajax update="formPanel"></p:ajax> </p:commandButton> 

をコード。あなたのボタンはどこですか? Beanスコープとは何ですか? getter/setterを表示します。ネストされたフォームはありますか?もう少し表示する.. –

+0

Beanスコープは@ViewScopedです。私は全体の景色を囲む1つのフォームしか持っていません。コードにボタンを追加しました。申し訳ありませんが、コードを読みやすくするためにトリムし、commandButtonを忘れました。 – baumlol

+0

バッキングビーン全体を見ることができますか? @ JaqenH'gharが述べたように、あなたはその豆腐のセッターを失っている可能性があります –

答えて

1

ローカルでコードを実行し、問題を発見しました。コマンドボタンで、p:ajax呼び出しを削除します。

PrimeFacesのコマンドボタンは、デフォルトで有効になっています。

ので、この変更:問題の原因が示されていないように思える参照

@ManagedBean 
@ViewScoped 
public class xyzUI implements Serializable{ 

    private static final long serialVersionUID = 6259024062406526022L; 

    private String description; 
    private boolean noChange = false; 

    public xyzUI(){ 

    } 

    public void submitForm(){ 
     System.out.println(description); 
    } 

    public boolean isNoChange() { 
     return noChange; 
    } 

    public void setNoChange(boolean noChange) { 
     this.noChange = noChange; 
    } 

    public String getDescription() { 
     return description; 
    } 

    public void setDescription(String description) { 
     this.description = description; 
    } 

} 
+0

基本的に、OPは 'process =" @ form "の代わりに' process = "@ this" 'を間違って使いました。 http://stackoverflow.com/q/25339056も参照してください。 – BalusC

関連する問題