p:commandButton does not update containing datatable

UI Components for JSF
mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

22 Aug 2010, 13:12

I'm using PF 2.2 on Mojarra 2.0.3 and Tomcat 6.

I have the following setup:

Code: Select all

<p:outputPanel id="serviceupdate">
                    <p:dataTable id="servicetable" width="800" style="min-width:800px;width:800px;" var="item" value="#{customerAdministration.serviceList}" 
                                 paginator="true" rows="10" dynamic="true">
                        <p:column width="100">
                            <f:facet name="header">
                                <h:outputText value="#{sessionBean.text['active']}" />
                            </f:facet>
                            <h:outputText value="#{item.active}" />
                        </p:column>
                       ...
                        <p:column width="160">
                            <f:facet name="header">
                                <h:outputText value="#{sessionBean.text['action']}" />
                            </f:facet>
                            <p:commandButton immediate="true" rendered="#{not item.active}" value="#{sessionBean.text['activate']}" action="#{customerAdministration.activate(item.service.id)}" update="serviceupdate">

                            </p:commandButton>
                            <p:commandButton immediate="true" rendered="#{item.active}" value="#{sessionBean.text['deactivate']}" action="#{customerAdministration.deactivate(item.service.id)}" update="@parent">

                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
My problem is, that the backingBean works perfect but neither button does update the table. I tried both update with id of the table and the outputPanel but nothing works.

The dataTable is contained in a p:tab of a p:wizard which sits in the h:form.

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

26 Aug 2010, 16:22

Hm... I still didn't get this to work. Is it a naming container issue ?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

26 Aug 2010, 20:04

You need to use full client id of outputPanel or datatable, there is an issue with UIData client id implementation which I've notified both mojarra and myfaces about, when in a row, it appends the row index id causing an issue like this.

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

26 Aug 2010, 20:23

Hm... so that's why @parent won't work.

Is there a way to force the id of an outputPanel ? I can't use prependId="false".

My structure is h:form -> p:wizard -> p:tab -> p:outputPanel -> p:dataTable and the commandbutton is in each row. The correct method is called, it's just the update that doesn't work.

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

04 Sep 2010, 18:38

I have still the same issue, now i two additional panels.

How can I force the update of the outer outputPanel ? Is there a way with p:commandButton oncomplete to trigger a JS function that then updates the outputPanel ?

callahan
Posts: 768
Joined: 27 May 2010, 22:52

04 Sep 2010, 23:55

Hi,

There are some posts here that may be of help: http://primefaces.prime.com.tr/forum/vi ... 311#p16178

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

05 Sep 2010, 11:59

Hi,

yes, the issue seems related - although i don't want to delete, but update the row in the underlying model and then let the dataTable reflect these changes via ajax. Nevertheless, it does not even work without ajax.

But i found a "workaround" - not quite what I want, but it at least works:

In the "complex datatable"-showcase, it is shown howto update a dialog (placed outside the row) in combination with row-selection of the table. So now i first update my dialog and show it and then use two buttons inside the dialog to modify the selected row. This works, because the buttons are outside the table and thus can "update" the table.

Anyway, I'll try with the full id, which in my case is a little bit longer due to multiple f:subview tags that i need because the layout is pretty dynamic.

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

05 Sep 2010, 12:49

I can confirm:

If i use full ids in the update, it works. Something like this is the solution:

Code: Select all

<h:form id="form">
...

<p:dataTable id="table" var="item" value="#{something.list}">
...
<p:column>
...
<p:commandButton action="#{something.action(item.id)}" update="form:table"/>
...
</p:column>
</p:dataTable>
...
</h:form>
Now it's just the issue that remains, that you can not predict the id in a portal-like environment with dynamic subviews...

callahan
Posts: 768
Joined: 27 May 2010, 22:52

05 Sep 2010, 13:24

Does it by any chance work if you use the p:component EL function like this:

<p:commandButton action="#{something.action(item.id)}" update="#{p:component('table')}"/>

If not, you could use a "special" RequestScoped backing bean that binds to the dataTable and can be used to determine it's full id.

mbauer77
Posts: 66
Joined: 04 Jan 2010, 14:41
Location: Munich, Germany
Contact:

05 Sep 2010, 13:31

Hm...

you mean a "wrapper" bean, that reads the values for the datatable from the original "something"-SessionScoped bean, but acts towards JSF as the binding component.
Yes, that could work. Good idea, thanks, I'll try that !

Does "p:component" work equal to the RichFaces' "component" - function ? Then this could work, too.
I did not recognize the "p:component"-function yet and can not use RF, because I don't want to step back to JSF 1.2 with this project.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 69 guests