How the setect itens example works???
angelogalvao Aug 3, 2006 11:54 AMi m looking this code in the select itens examples:
package org.jboss.seam.example.selectitems;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Remove;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.selectitems.SelectItems;
@Name("selector")
@Scope(ScopeType.SESSION)
public class SelectorAction implements Selector, Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
private String selected = "Mark";
public String getSelected()
{
return selected;
}
public void setSelected(String selected)
{
this.selected = selected;
}
@SelectItems(valueStrategy=SelectItems.Strategy.STRING)
public List items;
@Factory("items")
public List getItems()
{
items = new ArrayList();
items.add("Jim");
items.add("Dan");
items.add("Mark");
ArrayList<String> subgroup = new ArrayList<String>();
subgroup.add("Other Developers");
subgroup.add("Steve");
subgroup.add("Ananda");
items.add(subgroup);
return items;
}
public void select()
{
System.out.println("You selected: "+selected);
if("Dan".equals(selected))
{
System.out.println("Updating selected to Jim");
selected = "Jim";
}
}
@Remove @Destroy
public void destroy()
{
// TODO Auto-generated method stub
}
}
and that
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>SelectItems Example</title>
</head>
<body>
<f:view>
Selecting Dan will automatically change selection to Jim.
<h:form>
<h:selectOneListbox size="10" value="<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
<head>
<title>SelectItems Example</title>
</head>
<body>
<f:view>
Selecting Dan will automatically change selection to Jim.
<h:form>
<h:selectOneListbox size="10" value="#{selector.selected}">
<f:selectItems value="#{items}"/>
</h:selectOneListbox>
<h:commandButton type="submit" value="Select" action="#{selector.select}"/>
</h:form>
Currently selected developer is <h:outputText value="#{selector.selected}" />
<p/>
<h:outputLink value="/seam-selectitems">
<h:outputText value="Return to main menu" />
</h:outputLink>
</f:view>
</body>
</html>">
<f:selectItems value="#{items}"/>
</h:selectOneListbox>
<h:commandButton type="submit" value="Select" action="#{selector.select}"/>
</h:form>
Currently selected developer is <h:outputText value="#{selector.selected}" />
<p/>
<h:outputLink value="/seam-selectitems">
<h:outputText value="Return to main menu" />
</h:outputLink>
</f:view>
</body>
</html>he do this #{selector.select} to insert the vaule of select in the bean, but i try something like that e a have a property not found exception, from jsf el..
how do i do this???