开发者

How to capture value from textarea during form submission

I am using textarea to capture book description but textarea doesn't have attribute "value", How to pass the value to bean.

But the following mechanism to capture value doesn't seem to work

<textarea cols="80" rows="3" spellch开发者_StackOverfloweck="false">#{_book.description}</textarea>


did you try h:inputTextarea

 <h:inputTextarea value="#{bean.text}" cols="35"/>

link

EDIT:

 <div spellcheck="false">
    <h:inputTextarea value="#{user.test}" cols="80" rows="25"/>
    </div>

This seems to disable spell check for the given text area even though you enable it in firefox . I have tested in firefox only though.


If the h:inputTextArea is really no option for some reason, then just give it a name and grab it as request parameter the usual way as you would do when not using JSF at all.

E.g.

<textarea name="foo">#{bean.foo}</textarea>

with

@ManagedProperty(value="#{param.foo}")
private String foo;

or if you aren't on JSF 2.0 yet:

<managed-property>
     <property-name>foo</property>
     <value>#{param.foo}</value>
</managed-property>

or if you'd like to do it manually:

public Bean() {
    this.foo = FacesContext.getCurrentInstance().getExternalContext()
        .getRequestParameterMap().get("foo");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜