简体   繁体   中英

h:inputTextarea doesn't work in rich faces

Input Textarea value is never set on the bean side. JSF 1.2 with RichaFaces 3.3.3. Have next code:

<h:form id="name" rendered="#{not empty controller}">
            <h:panelGrid columns="1" styleClass="medium" columnClasses="subtitle,medium" style="text-align: left;" cellspacing="3px">
                <f:facet name="header">
                    <h:outputText value="Comments"/>
                </f:facet>

                <h:inputTextarea value="#{controller.comments}" rows="10" cols="80"
                        immediate="true"></h:inputTextarea>

                <div align="right">
                    <a4j:commandButton value="#{msg['label.save']}" action="#{controller.saveData()}" reRender="name" />
                </div>
            </h:panelGrid>
        </h:form>

And in the bean:

public void saveData(){
    //logic
}

public String getComments(){
    return "comments";
}

public void setComments(String comments){
    //logic
}

The jsf page is included in another page through ui:include and gets needed bean as a controller parameter.

Comments are read through get method, however, setter is never called, neither is saveData function. The same controller is used for some other data on another page and there literally the same saveData method works great. I wonder why Textarea value is never set?

The error you're getting is for this line:

<a4j:commandButton value="#{msg['label.save']}"
    action="#{controller.saveData()}" reRender="name" />

In JSF1.2, you shouldn't use the parenthesis in the action. Change it for

<a4j:commandButton value="#{msg['label.save']}"
    action="#{controller.saveData}" reRender="name" />

Also, check that the page you're posting is not inside on another form when you call it.

UPDATE:

Based on your last comment, I guess your problem could be in this sentence:

<h:form id="name" rendered="#{not empty controller}">

If controller is a request bean, then it will be empty on the request, thus the values inside yout form won't be sent or either activated. You can try to keep your bean with request scope and add the @KeepAlive annotation for your bean class:

@KeepAlive(ajaxOnly=false)
public class ControllerBean {
    //your bean logic...
    public void saveData(){
    //logic
    }

    public String getComments(){
        return "comments";
    }

    public void setComments(String comments){
        //logic
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM