1

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?

egaga
  • 21,042
  • 10
  • 46
  • 60

3 Answers3

4

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;
    }
}
Tair
  • 3,779
  • 2
  • 20
  • 33
2

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

Stefano Travelli
  • 1,889
  • 1
  • 15
  • 18
  • Do you happen to know is there a corresponding feature in Seam3? What kind of alternative have people used when migrated? Thanks! – egaga Aug 14 '11 at 12:26
0

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>
parasietje
  • 1,529
  • 8
  • 36