Question

I cannot seem to find where is @DataModel and @DataModelSelection in Seam3 (as opposed to Seam2). In what Seam module are they defined? If their name has been changed, what is it currently?

Was it helpful?

Solution

Assuming you are using JSF2.0, you can 'inject' selection to action methods like this:

<h:dataTable value="#{itemManager.itemList}" var="item">
   <h:column>
      <f:facet name="header">Item Id</f:facet>
      #{item.id}
   </h:column>
   <h:column>
      <f:facet name="header">Item Name</f:facet>
      #{item.name}
   </h:column>
   <h:column>
      <f:facet name="header">Action</f:facet>
      <h:commandLink value="Delete" action="#{itemManager.delete(item)}" />
   </h:column>
</h:dataTable>

and corresponding managed bean:

@ManagedBean(name="itemManager")
@SessionScoped
public class ItemManager {
    ArrayList<Item> itemList;

    public ArrayList<Item> getItemList() {
        if (itemList == null) {
            itemList = ... // build item list
        }
        return itemList;
    }

    public String delete(Item item) {
        itemList.remove(item);
        return null;
    }
}

OTHER TIPS

@DataModel and @DataModelSelection feature is not available in Seam3.

I you use richfaces, you can use the following construct:

<a:commandLink value="Delete" action="#{bean.delete}">
  <f:setPropertyActionListener value="#{item}" target="#{bean.selectedItem}" />
</a:commandLink>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top