简体   繁体   English

h:inputTextarea 在 rich faces 中不起作用

[英]h:inputTextarea doesn't work in rich faces

Input Textarea value is never set on the bean side.输入 Textarea 值永远不会在 bean 端设置。 JSF 1.2 with RichaFaces 3.3.3. JSF 1.2 与 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. jsf 页面通过 ui:include 包含在另一个页面中,并作为controller参数获取所需的 bean。

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.注释通过 get 方法读取,但是,setter 从未被调用, saveData function 也没有被调用。相同的 controller 用于另一页上的一些其他数据,并且实际上相同的saveData方法工作得很好。 I wonder why Textarea value is never set?我想知道为什么从未设置 Textarea 值?

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.在 JSF1.2 中,您不应在操作中使用括号。 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.如果controller是一个请求 bean,那么它将在请求中为空,因此您的表单中的值将不会被发送或激活。 You can try to keep your bean with request scope and add the @KeepAlive annotation for your bean class:您可以尝试使用请求 scope 保留您的 bean,并为您的 bean class 添加 @KeepAlive 注释:

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

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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