0

I have a <h:dataTable> adds contents of an input text to a list in a nested <h:dataTable>. A hidden command button is linked to the input text Problem is only the first input text's action method work, hence only list attached to the first thread of the parent message is updated not the consecutive once.

    <p:tabView id="tabView">
        <p:tab id="tab1" title="Conversation">
            <h:form id="pol">
                <p:dataTable var="message"
                    value="#{channelBean.getBean('channel').messageList}"
                    id="messageListTable">
                    <p:column>
                        <f:facet name="header">Photo</f:facet>
                        <h:outputText value="Photo" />
                    </p:column>
                    <p:column>
                        <f:facet name="header">Message</f:facet>
                        <p:panelGrid columns="1">
                            <p:panelGrid columns="3">
                                <h:outputText value="#{message.sender}" />
                                <h:outputText rendered="#{message.channel!=null}"
                                    value="#{message.channel.name}" />
                                <h:outputText value="#{message.message}" escape="false" />
                            </p:panelGrid>
                            <p:panelGrid columns="8">
                                <h:outputText value="#{message.postedString}" />
                                <h:form>
                                    <p:commandLink id="likeLink" value="UnLike"
                                        rendered="#{message.liked}" update="@parent" ajax="false">
                                        <f:actionListener binding="#{channelBean.like(message)}" />
                                    </p:commandLink>
                                    <p:commandLink id="unLikeLink" value="Like"
                                        rendered="#{!message.liked}" update="@parent" ajax="false">
                                        <f:actionListener binding="#{channelBean.unLike(message)}" />
                                    </p:commandLink>
                                    <h:outputText value="." />
                                    <h:outputText value="Reply" />
                                    <h:outputText value="." />
                                    <h:outputText value="Share" />
                                    <h:outputText value="." />
                                    <p:commandLink id="moreLink" value="More" />
                                    <p:menu overlay="true" trigger="moreLink" my="left top"
                                        at="left bottom">
                                        <p:menuitem value="Save" icon="ui-icon-disk" />
                                        <p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
                                    </p:menu>
                                </h:form>
                            </p:panelGrid>
                        </p:panelGrid>
                    </p:column>
                </p:dataTable>
            </h:form>
        </p:tab>
        <p:tab id="tab2" title="Info">
            <h:form id="channelViewForm">
                <l:inputTextarea
                    cid="com_fourforbusiness_esm_shared_domain_ffbesm_Channel_description"
                    label="#{msg.description}:"
                    value="#{channelBean.getBean('channel').description}" />
                <p:commandLink value="#{msg.save}"
                    update=":sideBarForm:subscribedChannels,@parent">
                    <f:actionListener
                        binding="#{channelBean.saveChannel('channel')}" />
                </p:commandLink>
            </h:form>
        </p:tab>
        <p:tab id="tab3" title="File"></p:tab>
        <p:tab id="tab4" title="Notes"></p:tab>
    </p:tabView>
</p:panel>

<p:panel id="inbox" visible="#{mainViewBean.currentView=='IN_BOX'}"
    autoUpdate="true">
    <h:form id="pol">
        <p:dataTable var="message"
            value="#{channelBean.subscribedChannelsMessages}"
            id="messageListTable"

            >
            <p:column>
                <f:facet name="header">Photo</f:facet>
                <h:outputText value="Photo" />
            </p:column>
            <p:column>
                <f:facet name="header">Message</f:facet>
                <p:panelGrid columns="1">
                    <p:panelGrid columns="3">
                        <h:outputText value="#{message.sender}" />
                        <h:outputText rendered="#{message.channel!=null}"
                            value="#{message.channel.name}" />
                        <h:outputText value="#{message.message}" escape="false" />
                    </p:panelGrid>
                    <p:panelGrid columns="8" id="panelx">
                        <h:outputText value="#{message.postedString}" />
                        <h:form>
                            <p:commandLink id="likeLink" value="UnLike"
                                rendered="#{message.liked}" update="@parent" ajax="false">
                                <f:actionListener binding="#{channelBean.like(message)}" />
                            </p:commandLink>
                            <p:commandLink id="unLikeLink" value="Like"
                                rendered="#{!message.liked}" update="@parent" ajax="false">
                                <f:actionListener binding="#{channelBean.unLike(message)}" />
                            </p:commandLink>
                            <h:outputText value="." />
                            <p:commandLink id="replyLink" value="Reply" action="#{channelBean.enabletextbox}" process="@this" ajax="true" update=":pol">

                            </p:commandLink>

                            <h:outputText value="." />
                            <h:outputText value="Share" />
                            <h:outputText value="." />
                            <p:commandLink id="moreLink" value="More" />
                            <p:menu overlay="true" trigger="moreLink" my="left top"
                                at="left bottom">
                                <p:menuitem value="Save" icon="ui-icon-disk" />
                                <p:menuitem value="Update" icon="ui-icon-arrowrefresh-1-w" />
                            </p:menu>
                            <BR></BR>
                            <p:inputText value="#{channelBean.repli}" rendered="#{channelBean.replyClicked}" id="replyTxt"  ></p:inputText>
                            <p:commandButton value="repSave" ajax="true" actionListener="#{channelBean.addMessage(message)}" rendered="#{channelBean.replyClicked}" update=":pol" style="visibility: hidden;" oncomplete="alert('#{message.message}');"> </p:commandButton>


                            <p:dataTable var="rep" id="replyListTable" value="#{message.replyList}">  
                                <p:column headerText="Replies">  
                                    <h:outputText value="#{rep.reply}" />  
                                </p:column>  
                          </p:dataTable>  
                        </h:form>
                    </p:panelGrid>
                </p:panelGrid>
            </p:column>
        </p:dataTable>
    </h:form>
</p:panel>

Backing bean:

public void addMessage (Message msg)
{

    List<Message> subList=this.getSubscribedChannelsMessages();
    for(Message mess:subList)
    {
        if(mess.getMessage().equalsIgnoreCase(msg.getMessage()))
        {
            msg.getReplyList().add(new Reply (repli));
            repli = "";
            replyClicked = false;
        }
    }


}

public void enabletextbox()
{
    if (replyClicked==false)
        replyClicked =true;
    else 
        replyClicked = false;
}

I don't understand why the <p:commandButton> of the nested <h:dataTable> doesn't invoke its actionListener. How is this caused and how can I solve it?

user1983983
  • 4,793
  • 2
  • 15
  • 24
  • Duplicate of [h:commandLink / h:commandButton is not being invoked](http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked) (point 2). You've there a nested ``. This is invalid in HTML. – BalusC Nov 14 '13 at 13:25
  • @BalusC thankyou for being there, removing the nested form is currently out of the question, any advice on how to make it work as is. – Mr.Magician Nov 14 '13 at 13:47

0 Answers0