简体   繁体   English

JSF 2.0 - 将“h:inputTextarea”嵌套在“h:repeat”中时出现问题

[英]JSF 2.0 - Problem getting 'h:inputTextarea' nested in a 'h:repeat'

Im just moving my project to JSF2.0 and im having this problem.我只是将我的项目移动到 JSF2.0 并且我遇到了这个问题。 I just cant get an inputTextarea that is inside ah:repeat.我只是无法获得位于 ah:repeat 中的 inputTextarea。 Outside the repeat, works great...在重复之外,效果很好......

Does anyone knows solution for this?有谁知道这个的解决方案? Im guessing it is a simple matter.我猜这是一件简单的事情。

The View: (only what matters)观点:(只有重要的)

    <ui:repeat value="#{pub.commentList}" var="com">
    <h:panelGroup>
                        <h:form id="pub" >                                            
                            <h:inputTextarea id="comment2" value="#{classController.msgComment}"  />                        
                            <div>
                                <h:commandButton type="submit" value="Postar" action="#{classController.saveComment}"  />                            
                            </div>
                        </h:form>
                    </h:panelGroup>
    </ui:repeat>

tha bean is all normal.豆豆一切正常。 Just a get/set for the property "msgComment".只是属性“msgComment”的获取/设置。

Thanks for the replies!感谢您的回复!

You need to bind the value to the currently iterated object, not to the parent managed bean.您需要将值绑定到当前迭代的 object,而不是父托管 bean。

<h:inputTextarea id="comment2" value="#{com.msgComment}" />

I think what you want to do is (assuming your container supports EL 2.2):我认为您想要做的是(假设您的容器支持 EL 2.2):

<ui:repeat value="#{pub.commentList}" var="com">
    <h:panelGroup>
        <h:form id="pub" >                                            
            <h:inputTextarea id="comment2" value="#{com.msgComment}"  />                        
            <div>
                <h:commandButton type="submit" value="Postar" action="#{classController.saveComment(com)}"  />                            
            </div>
        </h:form>
    </h:panelGroup>
</ui:repeat>

And in your classController bean:在你的classController bean 中:

public String saveComment(Comment com) {
    //do stuff
    return "success"; //or anything
}

If you don't have EL 2.2, you should do some simple workaround with setPropertyActionListener .如果您没有 EL 2.2,您应该使用setPropertyActionListener做一些简单的解决方法。

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

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