1

I'm using JSF and I have a form that contains a panelGroup and this panelGroup contains two commandLinks and a dataTable. The dataTable contains some commandLinks too. All commandLinks call a method of a JavaBean via AJAX.

And now the problem. If I click on the commandLinks link_edit or link_cancel the panelGroup is getting rerenderd. But if I click on a commadLink inside the dataTable like link_delete the panelGroup is not getting rerendered. Does anybody know what I'm doing wrong?

Here is the relevant section of the file:

    <h:panelGroup
        id="panel_destinations">
            <h:commandLink 
                id="link_edit"
                value="Edit" 
                styleClass="link"
                rendered="#{not editRoute.inEditDestinationMode}">
                 <f:ajax
                    listener="#{editRoute.editDestinations()}" 
                    render="panel_destinations"
                    immediate="true"/> 
            </h:commandLink>
            <h:commandLink 
                id="link_cancel"
                value="Abbrechen"
                styleClass="link"
                rendered="#{editRoute.inEditDestinationMode}">
                <f:ajax
                    listener="#{editRoute.cancelEditDestinations()}"                
                    immediate="true"
                    render="panel_destinations"/> 
            </h:commandLink>                    
        <h:dataTable 
            value="#{editRoute.route.destinations}" 
            var="destination"
            styleClass="dest_table"
            headerClass="route_table_header"
            rowClasses="route_table_row_odd,route_table_row_even"
            rendered="#{editRoute.hasDestinations()}"
            id="table_destinations">            

            <h:column>          
                <h:commandLink 
                    styleClass="route_table_link"
                    value="Delete"
                    id="link_delete"
                    rendered="#{editRoute.inEditDestinationMode}" >
                    <f:ajax
                        listener="#{editRoute.deleteDestination(destination)}"
                        render="panel_destinations"/>   
                </h:commandLink>                    
            </h:column>
        </h:dataTable>
    </h:panelGroup>
Sneek
  • 106
  • 5
  • possible duplicate of [h:commandButton not working inside h:dataTable](http://stackoverflow.com/questions/8034428/hcommandbutton-not-working-inside-hdatatable) – dognose Jun 19 '15 at 14:56
  • Unfortunaly not. The answer from your link says that the list at processing time might differ from the list at display time. But even if I don't change the list editRoute.route.destinations the panelGroup is not rendered again. The strange thing is, that the methods which are given in the listener-attribute is called. Only the panelGroup does not rerender. – Sneek Jun 20 '15 at 16:41
  • Another fact: If I sperate panelGroup in an additonal form outside the existing form and rerender that new form it also works. But thats not what I want. – Sneek Jun 20 '15 at 17:00
  • Have you tried to adress the panel-group with something like `render="@form:panel_destinations` or `render=":panel_destinations"`? (or just for testing purpose `render="@form"`) – dognose Jun 21 '15 at 11:26
  • Also, please remove `rendered="#{editRoute.inEditDestinationMode}"` from the command link and test if its working without this. – dognose Jun 21 '15 at 11:28
  • `render="@form:panel_destinations`: I get an Exception: **javax.servlet.ServletException: @form:panel_destinations : Invalid id keyword specified for 'render' attribute.** `render=":panel_destinations"`: No rerendering of the panelGroup. `render="@form"`: This works (but I can not use this approach), Removing of `rendered="#{editRoute.inEditDestinationMode}"`: Also no rerendering of the panelGroup – Sneek Jun 21 '15 at 12:08
  • 1
    "This works" means the panel is properly updated? `@form` will update all elements of the form, so the prolem seems to be the way how you target the panel. (Usually if its wrong it should result in expressions you saw: Invalid id keyword specified... )You have to look at the generated ids in the source and then debug, where your target-expression is wrong... try to remove `rendered="#{editRoute.hasDestinations()}"` from the table and check again. – dognose Jun 21 '15 at 12:22
  • Dude, that totally solved my problem. The problem was how I addressed the panelGroup. I followed your advice and debugged the generated ids. I forgot, that the form that has the panelGroup as a child also had an id with the value "form_edit". I then address the panelGroup with `render=form_edit:panel_destination` and now everthing works like charm. Thanks – Sneek Jun 21 '15 at 12:45

0 Answers0