[jboss-user] [JBoss Seam] - Re: Need help with using ValueChangeEvent and SEAM

petemuir do-not-reply at jboss.com
Tue Jul 25 07:37:27 EDT 2006


The 'value' of the selectOne is not a SelectItem but a String (unless a converter is supplied). You might want to look at one of the @SelectItems annotations that will create the SelectItem list for you (based on a list of Strings).

@Stateless()
  | @Name("advancedSearch")
  | public class AdvancedSearchBean implements AdvancedSearchLocal {
  |     
  |     private String currentType;
  |     
  |     @Out
  |     private List<SelectItem> searchTypeList;
  |     
  |     @In
  |     private FacesContext facesContext;
  |     
  |     @Factory("searchTypeList")
  |     public void loadList() {
  |         setSearchTypeList(new ArrayList());
  |         getSearchTypeList().add(new SelectItem("1","1"));
  |         getSearchTypeList().add(new SelectItem("2","2"));
  |     }
  |     
  |     public void typeSelected(ValueChangeEvent event) {
  |         String value = (String) event.getNewValue();
  |         if ("1".equals(value)) {
  |             currentType = getSearchTypeList().get(0);
  |         } else if ("2".equals(value)) {
  |             currentType = getSearchTypeList().get(1);
  |         }
  |         //Not sure if this line is needed, it work without it
  |         facesContext.renderResponse();
  |     }
  |     
  |     public String getCurrentType() {
  |         return currentType;
  |     }
  |     
  |     public void setCurrentType(String currentType) {
  |         this.currentType = currentType;
  |     }
  |     
  |     public List<SelectItem> getSearchTypeList() {
  |         return searchTypeList;
  |     }
  |     
  |     public void setSearchTypeList(List<SelectItem> searchTypeList) {
  |         this.searchTypeList = searchTypeList;
  |     }
  | }

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960644#3960644

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960644



More information about the jboss-user mailing list