简体   繁体   中英

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. I just cant get an inputTextarea that is inside ah:repeat. 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".

Thanks for the replies!

You need to bind the value to the currently iterated object, not to the parent managed bean.

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

I think what you want to do is (assuming your container supports 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:

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 .

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