I'm trying to nest <h:dataTable> with <s:link> elements without success.
Actually I can render a 2-level nested data table but if I click on the
innermost links I get null passed to the action method. Clicking on the
top-level links works fine and the expected objects are passed tomy action
method. Frustrating!
The rendered nested tables look something like this (everything rendered is a
clickable s:link element--bold represents the outer table and regular text the
inner nested tables):
| One
| Big Projects
| Small Projects
| Two
| Hot
| Cold
| Three
| Misc
|
A list of trivial Blah objects holds the One/Two/Three. Each Blah also has a
list of Bucket objects. This is supposed to simulate a 1-to-m Entity
relationship loaded from a database. I also have a stateful session bean,
Year, that manages things.
Here's the important clip from my xhtml that renders the tables.
| <h:dataTable id="outerTable"
| var="z"
| value="#{list}">
| <h:column>
| <s:link value="#{outer.name}" action="#{year.selectItem(outer)}"/>
| <h:dataTable id="innerTable"
| var="inner"
| value="#{outer.buckets}">
| <h:column>
| <s:link value="#{inner.name}"
action="#{year.selectBucket(inner)}"/>
| </h:column>
| </h:dataTable>
| </h:column>
| </h:dataTable>
|
Here are the important bits from Year.java
| @Stateful
| @Name("year")
| @Scope(ScopeType.SESSION)
| public class YearBean implements Year {
| @DataModel
| private List<Blah> list;
|
| @Create
| public void init() {
| // Create & populate 2-tier data structure simulating loaded
Entites
| list = new ArrayList<Blah>();
| List<Bucket> b = new ArrayList<Bucket>();
| b.add( new Bucket("Big Projects"));
| b.add( new Bucket("Small Projects"));
| list.add(new Blah("One",b));
|
| b = new ArrayList<Bucket>();
| b.add( new Bucket("Hot"));
| b.add( new Bucket("Cold"));
| list.add(new Blah("Two",b));
|
| b = new ArrayList<Bucket>();
| b.add( new Bucket("Misc"));
| list.add(new Blah("Three",b));
| }
|
| public String selectBucket(Bucket bucket) {
| if( bucket == null )
| System.out.println("+++>>> Null Bucket Selected! ");
| else
| System.out.println("++++>>> Bucket selected: " +
bucket.getName());
| return "bucket";
| }
|
| public String selectItem(Blah blah) {
| if( blah == null )
| System.out.println("+++>>> Null Blah Selected! ");
| else
| System.out.println("++++>>> Blah selected: " +
blah.getName());
| return "blah";
| }
|
| }
|
And finally Blah.java and Bucket.java:
| @Name("blah")
| public class Blah {
| private String name;
|
| @DataModel
| private List<Bucket> buckets;
|
| public Blah(){}
|
| public Blah(String name, List<Bucket> buckets) {
| this.name = name;
| this.buckets = buckets;
| }
| public String getName() { return name; }
| public List<Bucket> getBuckets() { return buckets; }
| }
|
|
| @Name("bucket")
| public class Bucket {
| private String name;
|
| public Bucket(){}
|
| public Bucket(String name) {
| this.name = name;
| }
| public String getName() { return name; }
| }
|
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4018347#4018347
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4018347
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user