2
votes

I asked this in the PF Forum but no one seems to want to answer so I though I'd try my luck here.

I have a ui:repeat that is not being updated correctly after an Ajax call when it is within a TabView.

Simple scenario is I have a ui:repeat pointing at an ArrayList (ArrayList contains simple pojos with a String). Within this I have an h:inputText whose value is the pojo's String getter/setter. The ui:repeat is contained within a h:panelGroup. I use a p:commandButton to run an action to update the ArrayList (just add a couple of objects to it a Math.random value for the String) and then update the h:panelGroup. The updated values in the ArrayList are not reflecting in the ui:repeat input fields. This only appears to be affecting input fields as outputText fields do update correctly. Also if I do the same for a p:dataTable the input field are updated correctly. If I remove the Tabview and Tab tags it works fine.

As it works when removing the Tabs I can only assume this is a bug and not designed to work like this. If someone could please confirm if this is so or if there is a viable work around. I need to use a ui:repeat as my fields are not in a tabular format. This has only occurred since migrating from PF 2.2. I'm currently on PF 3.1, Weblogic 10.3.4 and Mojarra 2.0.4

<p:tabView>
    <p:tab title="Test">

        <h:form prependId="false">

            <p:commandButton id="testStringCheck"
                             value="Test String Check"
                             process="@form"
                             update="testPanel"
                             action="#{testBean.generateVOwithRandomStrings}">
            </p:commandButton>

            <h:panelGroup id="testPanel" layout="block">
                <ui:repeat value="#{testBean.voList}" var="entry">
                    <h:outputText value="#{entry.randomString}"/>
                    <p:inputText style="display:block;"
                                 value="#{entry.randomString}"
                                 size="15">
                    </p:inputText>
                </ui:repeat>
            </h:panelGroup>

        </h:form>

    </p:tab>
</p:tabView>
3

3 Answers

1
votes

As a workaround I've used a p:datagrid instead of a ui:repeat. This achieves the look I had in the the ui:repeat so I'm happy. Hopefully this bug will be fixed on future releases.

0
votes

This is something of a bug in Primefaces commandButton. See the following thread:

http://forum.primefaces.org/viewtopic.php?f=3&t=17454

You can try replacing

<p:commandLink id="testStringCheck" ... update="@form" />

With an <h:commandLink>

<h:commandLink id="testStringCheck" render="@form"/>

Also from the above link here is an interesting method that somebody posted that enables you to correctly find the correct clientId to update.

http://paste.kde.org/177698/

0
votes

temp solution: insert outside h:panelGroup:

<p:outputPanel defered="true" delay="1" ..> 

and update outputPanel instead of panelGroup

Or use a datalist component instead of ui:repeat.

One more, i'm not sure but you can try, so update class instead id:

<h:panelGroup id="testPanel" layout="block" styleClass="testPanelCl" ../>

and update : @(.testPanelCl), don't forget id of panelGroup, without id JSF can not update by class