GeeCON Prague 2014*
The moose likes JSF and the fly likes f:ajax not working inside c:forEach Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "f:ajax not working inside c:forEach" Watch "f:ajax not working inside c:forEach" New topic
Author

f:ajax not working inside c:forEach

Ifta Khirul
Greenhorn

Joined: Nov 27, 2012
Posts: 6
Hi,

I want to use f:ajax inside c:forEach Tag. But it is not working .



How can I make it workable ? If i place the h:inputText outside c:forEach then it works perfectly.
But my textbox are dynamic and they will be generated inside the c:forEach tag block.

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

As a general rule, you should shun JSTL in JSF View definitions. They cause many problems and there are ways to do the same thing in native JSF with less trouble.

When attempting to present a collection of objects in a JSF View, I recommand that you first consider using the h:dataTable tag. For cases where the tabular layout that dataTable provides isn't suitable, the fallback would be the ui:repeat JSF tag.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ifta Khirul
Greenhorn

Joined: Nov 27, 2012
Posts: 6
Hi,
Thanks for your reply.

I have removed c:forEach and used ui:repeat but still it is not working.



after rendering the view completely if i take the code of the component using firebug or view source - then i get the following code



that means it generated the onkeyup events but it is not executing the backend method.

Any clue ?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16101
    
  21

When a backing method won't fire, it's one of the following:

1. The control(s) are not contained in an h:form (yours is, according to your source HTML)

2. Values in one or more of the form controls are invalid (h:messages element will display validation errors)

3. The name of the bean or method is misspelled or miscapitalized (if the method cannot be located, it isn't called and no error is generated).
3a. Same thing applies to the View attribute name (action=, listener= or whatever) that binds the method to the view.

4. The signature of the method is incorrect. In the case of an AJAX action, it should either be "public void saveFactValue()" or "public void saveFactValue(AjaxListenerEvent event)". Or whatever "AjaxListenerEvent" is actually called. I don't remember.
Ifta Khirul
Greenhorn

Joined: Nov 27, 2012
Posts: 6
I understood the case. But in the current scenario the backend bean method is being called when the textbox is outside ui:repeat tag. Which means that the backend bean configuration are ok.
Anyway thanks for your quick and helpful responses. I will try to investigate more.

 
Don't get me started about those stupid light bulbs.
 
subject: f:ajax not working inside c:forEach