1

I have seen the answer by BalusC and the solution with changing the scope, but I tried it and I think there is yet another problem that seems not really solvable using JSF2.

I have created a custom component that extends UIData. This custom component displays a table with rows of the data, it is called PagingDataTable. It cotains PagingDataColumns that can then be clicked and the sort ordering is changed etc...

This works fine, but as soon as I add a h:CommandButton inside a PagingDataColum, the action of the button is not invoked. Let me explain this:

  • It works when using a nested f:ajax element
  • But it does not work when just defining an action in the h:CommandButton without nesting

In this special case I don't want to use Ajax for it. I debugged it and I found out a mismatch in the Mojarra implementation of the ButtonRenderer class (method wasClicked). Inside this method, it is checked whether the button was clicked, and this check is done according to the ID (actually the name, but this is the ID). But UIData components have two different IDs:

  • ID with rowIndex when the rowIndex exists, e.g. while rendering
  • ID without rowIndex when the rowIndex does not exist, e.g. when the user clicks the button

So the wasClicked() tries to find the ID without rowIndex in the parameter map, to no avail, and because of this, the action method is not invoked.

IMHO this is a bug in the ButtonRenderer.wasClicked() method, which would need to have additional logic to be able to understand that an ID without rowId is not an exact match in the parameter map with an ID with rowId.

Did I miss anything here? IMHO this has nothing to do with the scope of the underlying data, because the rowId is not there in any case, independent of the scope. But I tried it with SessionScoped, and the same thing is happening.

I also download version 2.1.28 of Mojarra: the same thing is happening. Mojarra 2.2.X seems not work easily with my Glasssfish server version, so I could not try it with the newest version. I am kind of stuck here, and actually the use case is quite simple: Add a button to any column of the pagingDataTable and let it invoke an action.

It would be possible to make a workaround for this, either by using Ajax or by doing some JS coding myself... but this should not be necessary in JSF2? Any help is appreciated.

msaladin
  • 405
  • 1
  • 5
  • 12

1 Answers1

0

OK, sorry for asking this question. It seems that when adding

<f:param name="cid" value="#{javax.enterprise.context.conversation.id}" /> 

nested in the h:commandButton, it will (magically) set the rowIndex of the row that was clicked, and the logic in ButtonRenderer is working again. Everything runs smoothly then.

msaladin
  • 405
  • 1
  • 5
  • 12