Problems using commandbutton in TreeTable

UI Components for JSF
Post Reply
bwright
Posts: 8
Joined: 09 Feb 2015, 10:29

25 Mar 2015, 11:06

Hi,
I have already posted this on stackoverflow[1] but did not get any response so here goes again:

I am having troubles using commandbutton in a treetable. The events are triggered correctly for the root elements in the tree, however any child elemts do not work.

TreeTable:

Code: Select all

<p:treeTable var="ou" 
    value="#{oumanagement.ouTree}" 
    class="userList" 
    id="outable"
    selectionMode="single">

    <f:facet name="header">
        <h:outputText value="List of Organisational Units" />
    </f:facet>

    <p:column headerText="Organisational Unit" >
        <h:outputText value="#{ou.name}" />
    </p:column>

    <p:column>
        <p:commandButton action="#{oumanagement.remove(ou.id)}" icon="fa fa-trash-o" update=":ouform:outable :ouform:msgs" transient="true">
           <p:confirm header="Are You Sure" message="Are you sure?" icon="ui-icon-alert" />
        </p:commandButton>
     </p:column>
     <p:column>
         <p:commandButton action="#{oumanagement.viewDetails(ou.id)}" icon="fa fa-sliders" transient="true"  ajax="false"/>
      </p:column>
</p:treeTable>
Action:

Code: Select all

public String viewDetails(int id) {
    activeOU = ouService.find(id);
    FacesContext.getCurrentInstance().getExternalContext().getFlash().put("ou", activeOU);
    return "/pages/secure/organisationManagement/details";
}
The only information I found was to add a button outside of the treetable and use selected row information. This however seems like a workaround not the solution, and would break user experience.

Any help is greatly appreciated.


PF version: 5.1
Using Spring-faces 2.4.1, jsf-api 2.2.10, jsf-imp 2.2.10

[1]: http://stackoverflow.com/questions/2921 ... ot-invoked

mor
Posts: 48
Joined: 24 Jun 2013, 10:47
Location: Zürich

25 Mar 2015, 17:16

Hi,

Have you tried using a actionListener instead of an action? see example below:

Code: Select all

<p:commandButton id="clearHistoryForm" type="push" styleClass="clantablebutton"
actionListener="#{dashboardBean.removeAllHistory(document)}"
process="@this" icon="ui-icon-trash" update="historyTreeTab"
rendered="#{document.id eq null and !document.today}" />
Regards
MOR

bwright
Posts: 8
Joined: 09 Feb 2015, 10:29

26 Mar 2015, 10:17

Hi,

Using ActionListener it does not work at all. Simply reloads the current view even when clicking root elements,

bwright
Posts: 8
Joined: 09 Feb 2015, 10:29

26 Mar 2015, 12:33

Ok i found out the actuall method is called:

Code: Select all

 public String viewDetails(int id) {
        activeOU = ouService.find(id);
        System.out.println("Pushing to Flash");
        FacesContext.getCurrentInstance().getExternalContext().getFlash().put("ou", activeOU);
        return "/pages/secure/organisationManagement/details.xhtml?faces-redirect=true";
    }
"Pushing to Flash" gets printed to the console.

However the page does not get redirected to the new view (with or witout faces-redirect=true).

Any ideas on what is going wrong here?

bwright
Posts: 8
Joined: 09 Feb 2015, 10:29

13 Apr 2015, 10:20

Updated to Primefaces 5.2 today. But sadly the problem still exists :-(

bwright
Posts: 8
Joined: 09 Feb 2015, 10:29

19 May 2015, 10:03

Ok for some reason I reimplemented the whole situation. I now have almost the same setup as the showcase for treetables.
My XHTML:

Code: Select all

 <h:form id="ouLisForm">
                <p:treeTable value="#{ouBean.rootOU}" var="ou">
                    <p:column headerText="Organisational Unit Name">
                        <h:outputText value="#{ou.name}" />
                    </p:column>
                    <p:column headerText="description">
                        <h:outputText value="#{ou.description}" />
                    </p:column>
                    <p:column style="width:24px">
                        <p:commandLink process="@this" update=":ouLisForm:documentPanel" oncomplete="PF('documentDialog').show()" title="View Detail" styleClass="ui-icon ui-icon-search">
                            <f:setPropertyActionListener value="#{ou}" target="#{ouBean.selectedOU}" />
                        </p:commandLink>
                    </p:column>
                </p:treeTable>

                <p:dialog id="dialog" header="Document Detail" showEffect="fade" widgetVar="documentDialog" modal="true" resizable="false">
                    <p:outputPanel id="documentPanel">
                        <p:panelGrid  columns="2" columnClasses="label,value" rendered="#{not empty ouBean.selectedOU}">
                            <h:outputLabel for="name" value="Name: " />
                            <h:outputText id="name" value="#{ouBean.selectedOU.name}" style="font-weight:bold" />

                            <h:outputLabel for="description" value="Size: " />
                            <h:outputText id="description" value="#{ouBean.selectedOU.description}" style="font-weight:bold" />

                        </p:panelGrid>
                    </p:outputPanel>
                </p:dialog>
            </h:form>
Parts of my Bean:

Code: Select all

public OrganisationalUnit getSelectedOU() {
        return selectedOU;
    }

    public void setSelectedOU(OrganisationalUnit selectedOU) {
        System.out.println("Selected OU: " + selectedOU.getName());
        this.selectedOU = selectedOU;
    }
The setSelectedOU is executed for Root elements only. whenever i click a child this method is not called, and the value not updated. My bean is ViewScoped.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 46 guests