1

My xhtml, If i put my CommandButton into the h:form the Actionlistener is not called:

<ui:composition template="/template.xhtml">
    <style>

    </style>
    <ui:define name="title">
        <h:outputText value="#{bundle.ListDashboardTitle}"></h:outputText>
    </ui:define>
    <ui:define name="body">
        <h:form id="formDashboard">
            <p:layout id="layoutVar" style="min-height:500px;">
                <p:layoutUnit id="gridLeft" position="west" size="250" style="position:absolute;">
                    <p:fieldset style="padding:0;padding-top:5px">
                        <f:facet name="legend" id="legendId">
                            <p:commandButton id="addEvent" type="button" icon="ui-icon-plus" value=""  onclick="addMemo.show()" update=":formAddMemo" style="width:30px;height:30px;"/>
                        </f:facet>
                        <p:dataGrid id="leftData" var="item" columns="1" value="#{myMemosController.items}" style="border:none;">
                            <p:panel id="pnl" styleClass="" style="background-color:#{item.priority}}" closable="true">
<!--                                <p:ajax event="close" listener=""/>-->
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="#{item.name}" styleClass=""/>
                                        <p:commandButton icon="ui-icon-pencil" actionListener="#{myMemosController.prepareEdit}" update=":editForm" onclick="editMemo.show();" style="width:19px;height:19px;"/>
                                    </h:panelGroup>
                                </f:facet>
                                <f:facet name="footer">
                                    <h:outputText value="#{item.date} at #{item.time}" styleClass="footerStyle"/>
                                </f:facet>
                                <h:panelGrid columns="1" style="width:100%">  
                                    <h:outputText value="#{item.comments}" styleClass=""/>
                                </h:panelGrid>
                            </p:panel>
                            <p:draggable for="pnl" helper="clone" handle=".ui-panel-titlebar" stack=".ui-panel" zindex="100"/>
                        </p:dataGrid>
                    </p:fieldset>
                </p:layoutUnit>

                <p:layoutUnit position="center" style="position:absolute;">
                    <p:outputPanel id="dropArea">
                        <p:dataTable id="centerGrid" value="#{dashboardController.items}" var="item">
                            <p:column style="text-align:center;">
                                <f:facet name="header">
                                    <h:outputText value="Priority"/>
                                </f:facet>
                                <h:outputText value="#{item.priorityname}"/>
                            </p:column>
                            <p:column style="text-align:center;">
                                <f:facet name="header">
                                    <h:outputText value="Name"/>
                                </f:facet>
                                <h:outputText value="#{item.name}"/>
                            </p:column>
                            <p:column style="text-align:center;">
                                <f:facet name="header">
                                    <h:outputText value="Comment"/>
                                </f:facet>
                                <h:outputText value="#{item.comments}"/>
                            </p:column>
                            <p:column style="text-align:center;">
                                <f:facet name="header">
                                    <h:outputText value="Time"/>
                                </f:facet>
                                <h:outputText value="#{item.time}"/>
                            </p:column>
                            <p:column style="text-align:center;">
                                <f:facet name="header">
                                    <h:outputText value="Date"/>
                                </f:facet>
                                <h:outputText value="#{item.date}"/>
                            </p:column>
                        </p:dataTable>
                    </p:outputPanel>
                    <p:droppable id="droppablePanel" tolerance="touch" activeStyleClass="ui-state-highlight">  

                    </p:droppable>
                </p:layoutUnit>

                <p:layoutUnit id="gridRight" position="east" size="250" style="position:absolute;">
                    <p:dataGrid id="rightGrid" var="item" columns="1" value="#{usersMemosController.items}">
                        <p:panel id="pnl" styleClass="" style="background-color:#{item.priority}}" closable="true">

                            <f:facet name="header">
                                <h:outputText value="#{item.name}" styleClass=""/>
                            </f:facet>
                            <f:facet name="footer">
                                <h:outputText value="#{item.date} at #{item.time}" styleClass="footerStyle"/>
                            </f:facet>
                            <h:panelGrid columns="1" style="width:100%">  
                                <h:outputText value="#{item.comments}" styleClass=""/>
                            </h:panelGrid>
                        </p:panel>
                        <p:draggable for="pnl" helper="clone" handle=".ui-panel-titlebar" stack=".ui-panel" zindex="100"/>
                    </p:dataGrid>
                </p:layoutUnit>
            </p:layout>
        </h:form>

        <p:dialog id="dialogEditMemo" header="Edit Memo" widgetVar="editMemo" resizable="false" closable="true" closeOnEscape="true" draggable="false">
            <h:form id="editForm">
                <h:messages style="color:red;margin:8px;" />

                <h:panelGrid columns="1" cellpadding="3">
                    <p:inputTextarea id="commentEditInput" value="#{myMemosController.currentComment}" rows="6" required="true">
                        <p:ajax event="keyup" />
                        <p:ajax event="change" />
                    </p:inputTextarea>
                    <p:watermark for="commentEditInput" value="Enter your memo..."/>

                    <h:panelGrid columns="2" cellpadding="1">
                        <h:outputLabel for="selectEditShare" value="Share Memo: " style="margin-right:40px;"/>  
                        <p:selectBooleanCheckbox id="selectEditShare" label="selectEditShare"/> 
                    </h:panelGrid>

                    <p:selectOneMenu id="chooseEditPriority" value="#{myMemosController.currentPriority}">  
                        <f:selectItem itemLabel="Low Priority" itemValue="Low Priority" />  
                        <f:selectItem itemLabel="Medium Priority" itemValue="Medium Priority" />  
                        <f:selectItem itemLabel="High Priority" itemValue="High Priority" />  
                    </p:selectOneMenu>
                </h:panelGrid>
            </h:form>
            <p:panel id="panelEditBtn" style="border:none;">
                <p:commandButton icon="ui-icon-close" value="Reset" type="reset"/>
                <p:commandButton icon="ui-icon-check" actionListener="#{myMemosController.update}" value="Edit" process="@this" update=":formDashboard:leftData" onsuccess="editMemo.hide();"/>
            </p:panel>
        </p:dialog>
    </ui:define>
</ui:composition>

When i want to display InputTextarea value is equal null:

public String update() {
  System.out.println(getCurrentComment());
}

Thanks in advance

Samolo
  • 75
  • 1
  • 13
  • Have you excluded #2 and #3 here http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked/2120183#2120183 from being the cause? (nested forms and conversion/validation errors). – BalusC Oct 08 '13 at 18:27
  • But when i call my `commandButton`outside of my `h:form`, my `actionListener`is called correctly. But my inputTextArea is still return null? However i correctly created my getter/setter. – Samolo Oct 08 '13 at 18:46
  • That's explained here: http://www.htmldog.com/guides/html/beginner/forms/ (keep in mind; JSF is in the context of that "problem" merely a HTML code generator). In a nutshell, all inputs need to go in the same form as the submit button if you want to have their values to be sent. Again, please exclude points #2 and #3 from the aforelinked answer. – BalusC Oct 08 '13 at 18:50
  • May be you have a suggestion about: Why my `actionListener` is not called when i put my `commandButton` into the `h:form`? I edited my post. – Samolo Oct 09 '13 at 13:08

2 Answers2

1

The problem is in your managedBean you have not instansiated the object currentComment . And Please try to avoid nested form in your application.

BholaVishwakarma
  • 581
  • 6
  • 18
0

I have gone with the same issue the issue is that sometime value is not set to the managedBean by ajax. So modify your <p:inputTextArea /> with the below code it works.

<p:inputTextarea id="commentEditInput"
  value="#{myMemosController.currentComment}"rows="6" required="true">
   <p:ajax event="keyup" />
   <p:ajax event="change" />
</p:inputTextarea>

And For your actionListener just try to use process attribute that might work..

<p:commandButton id="submitEditDialog" icon="ui-icon-check" 
  actionListener="#{myMemosController.update}" value="Edit"
  update=":formDashboard:leftData :editForm" onsuccess="editMemo.hide();"
  process="@this"
/>
miroslav_mijajlovic
  • 1,703
  • 17
  • 31
BholaVishwakarma
  • 581
  • 6
  • 18
  • I try your solution, but it doesn't work for me. My `inputTextarea` value still return null, and when i put my `commandButton` into the `h:form` the `actionListener`is not called. I really don't know where the problem is? – Samolo Oct 09 '13 at 12:55
  • No error, only this warning when i put `h:message`into my form: "The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within ". But when i do that my `actionListener`is not called. – Samolo Oct 09 '13 at 13:15
  • Yes i have Tean viewer. – Samolo Oct 09 '13 at 13:25