Search code examples
jsfjsf-2primefacesicefaces

Input Text is not changing in the bean variable


When i enter the data in the browser, it should suppose to set the variable parameter in the bean. But it is not setting for some reason. At one point it did work and again not anymore.

XHMTL

<p:panel header="Previous Summary" toggleable="true"
                toggleSpeed="500"
                style="border: 1px solid white; background-color: #F0F8FF; text-align: left;">
                <ice:form>
                    <ice:inputRichText id="editor_prevsummary"
                        value="#{statusReport.prevSummaryStr}" width="1200" height="200"
                        rendered="#{statusReport.renderPrevSummTextIn}"
                        onchange="this.form.submit()"  />


                    <ice:outputText value="#{statusReport.prevSummaryStr}"
                        rendered="#{!statusReport.renderPrevSummTextIn}" escape="false"></ice:outputText>
                    <br />
                    <ice:commandButton action="#{statusReport.editPrevSummary()}"
                        value="Edit" partialSubmit="true" />
                    <ice:commandButton action="#{statusReport.updatePrevSumm()}"
                        partialSubmit="true" value="Update"  />
                </ice:form>
            </p:panel>

Bean Values

  public String getExecSummaryStr() {

        return execSummaryStr;
    }

    public void setExecSummaryStr(String execSummary) {

        this.execSummaryStr = execSummary;
    }

I getting the same thing, even i change to inputText or anything. Not sure why it is happening and where i should start diagnosing the issue.


Solution

  • Your problem is because you're using the same variable for the <ice:inputRichText> and the <ice:outputText> inside the same form. When the form is submitted, the framework will set the value from both components into #{statusReport.prevSummaryStr}, leading to odd behavior in your site.

    EDIT:

    A possible solution could be moving the <ice:outputText> out of the form and rendering from your commandButton. Another solution could be using javascript to update its value. You can do something like:

    <ice:inputRichText id="editor_prevsummary"
        value="#{statusReport.prevSummaryStr}" width="1200" height="200"
        rendered="#{statusReport.renderPrevSummTextIn}"
        onchange="document.getElementById('divText').innerHTML = this.value"  />
    <div id="divText">
    
    </div>