Search |
||
ui:repeat and AjaxPosted by driscoll on August 17, 2009 at 2:35 PM PDT
A nice feature of Facelets is the ui:repeat tag, which iterates over a supplied list of values to do a full list on your page. One problem: it'll add an index to the generated id's, which can make using it with Ajax a bit of a drag. But if you're just using the f:ajax tag, that index is detected automatically, making ajaxifying the tag relatively easy. Here's a quick example:
Say you want to make a page that offers three drop down menus with three choices each (it's a simple example, work with me here). Here's the data structure, set up as a bean:
Now: to use it in a page:
Neat, huh? In case you're not familiar with the ui:repeat tag - you should take a minute to get familiar with it, it's core Facelets functionality. By using the var value, we're saying that we want to create a list variable that will contain one of the lists in llist every iteration. By using varStatus and the index property, we're keeping track of all of the values selected. Just a simple example of the use of the f:ajax tag in a complex rendered environment. As always, let me know if you have any questions. »
Related Topics >>
Web Applications Comments
Comments are listed in date ascending order (oldest first)
That's not JSF 2
Submitted by driscoll on Mon, 2009-11-02 16:06.
This blog entry is about JSF 2. The stuff you're working with is not JSF 2 - in fact, it's my understanding that RichFaces 3 doesn't work with JSF 2, and that they're working on RichFaces 4 to overcome that - but you'll need to check in with folks who work with RichFaces for more information - as well as the answer to your question.
Hi Jim! Is there a way to
Submitted by amitev on Tue, 2009-10-20 00:08.
Hi Jim! Is there a way to specify the row(s) index you want to update, not only the active row?
Just use the ID
Submitted by driscoll on Tue, 2009-10-20 07:57.
Rather than give you the answer, let me describe how to get the answer: Check the rendered ID - it's the attribute ID in the rendered row. You would then use that, possibly with a leading ":" if you are using the ajax tag, or just the straight ID, if you are using the JavaScript Ajax function.
I wonder why fo you list 36
Submitted by nzinoviev on Sun, 2009-11-01 04:29.
I wonder why fo you list
36 public String getResultArray(int i) {
37 return resultArray[i];
38 }
39 public void setResultArray(int i, String value) {
40 resultArray[i] = value;
41 }
I don't think these may be called from JSF EL expressions, right? I guess, even
42 public void setResultArray(String[] resultArray) {
43 this.resultArray = resultArray;
44 }
is not needed, it's not called by JSF, it's String[] getResultArray() which does all the tricks. (even though repeatBean.resultArray cannot be used as lvalue, repeatBean.resultArray[current.index] can. ----- Also, can you please comment on this ":" logic in ids specified in f:ajax? It looks sometimes :out makes sence or is it for the cases when prependId=false? Is there a set of rules somewhere which tell how those ids are resolved? (one cannot start with form: in a compositeComponent, so there should be a way to use local ids) (My original problem is that I'm trying to ajaxify a composite component which has ui:repeats and a lot of panel group render="..." which as I heard adds even more tricks...) UIComponent.findComponent has the rules
Submitted by driscoll on Mon, 2009-11-02 16:04.
The rules you are looking for are found in the JavaDoc for UIComponent.findComponent.
They're not especially simple, but they are useful - which is the point of this blog posting. prependId doesn't effect their interpretation - and a leading ":" means to just look for that id in the tree. So, ":out" will look for the toplevel component that has an id of "out". Even it's nested in a form with prependId=false, if the form id is "form", then the id you are looking for will still be ":form:out". |
||
|
Getting dynamic ids ui repeat - Please give your valuable inputs
//THIS WORKS FINE ... //NOT WORKING, SUGGESTIONACTION EVENT IS NOT FIRED .... Save...