代码之家  ›  专栏  ›  技术社区  ›  Achaius

如何在表单提交期间从textarea获取值

  •  0
  • Achaius  · 技术社区  · 14 年前

    我使用textarea捕获图书描述,但是textarea没有属性“value”,如何将值传递给bean。

    但是下面的获取价值的机制似乎不起作用

    <textarea cols="80" rows="3" spellcheck="false">#{_book.description}</textarea>
    
    2 回复  |  直到 14 年前
        1
  •  4
  •   BalusC    12 年前

    你试过了吗 h:inputTextarea

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

    link

    编辑:

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

        2
  •  1
  •   BalusC    14 年前

    h:inputTextArea

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

    具有

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

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

    或者如果您想手动执行:

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