Hi.
I am a newbie at Seam so please forgive what might seem to be an obvious
question...
I'm trying to implement some hierarchy navigation screens. Code is posted below:
| home.xhtml
| ...
| <div class="chierarchy">
| <h:dataTable value="#{categories}" var="cat">
| <h:column>
| <h:commandLink value="#{cat.name}"
action="#{catList.select}" />
| </h:column>
| </h:dataTable>
| </div>
| ...
|
| CategoryListBean.java
| ...
| @Stateful
| @Scope(SESSION)
| @Name("catList")
| @Interceptors(SeamInterceptor.class)
| public class CategoryListBean implements java.io.Serializable, CategoryList
{
|
| @DataModel
| private List<Category> categories;
|
| @Out(required=false)
| @DataModelSelection
| private Category category;
|
| @PersistenceContext(type=EXTENDED)
| private EntityManager em;
|
| @Factory("categories")
| public void findCategoryList() {
| long catId=1;
| try {
| catId=category.getCategoryId();
| } catch (Exception e) {}
| System.out.println(catId);
| categories = em.createQuery("from Category where parent_id = :parid")
| .setParameter("parid",catId)
| .getResultList();
| }
|
| public String select() {
| return "selected";
| }
|
| public String delete() {
| return "deleted";
| }
|
| @Remove @Destroy
| public void destroy () {}
|
| }
| ...
|
| Category.java
| ...
| @Entity
| @Name("category")
| public class Category implements java.io.Serializable {
|
| private long categoryId;
| private Collection<Asset> asset;
| private Collection<Category> children;
| private Category parent;
| private String name;
|
| public Category() {}
| ...
| /**
| * Get children.
| *
| * @return children as String.
| */
| @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER,
mappedBy="parent")
| public Collection<Category> getChildren()
| {
| return children;
| }
| ...
|
|
When a dataTable entry is selected in the browser, I am assuming that the
selected "Category" will be passed in as the @DataModelSelection attribute and
that the next time the table is rendered, the parent cateory will have changed.
Unfortunately, this doesn't happen. I don't seem to get the expected behaviour
and the page re-renders as before. Seeing as this is such a trivial problem, I
would be grateful if someone could set me straight here.
Thanks.
Mark
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3928341#3928341
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3928341
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user