[jboss-user] [JBoss Seam] - Re: SeamSelectItems - 1.1.1beta4

Frippe do-not-reply at jboss.com
Tue Feb 6 05:17:00 EST 2007


I have a stateless bean with that name as below.

I've removed a few things from this class which has no bearing on the current problem.


@Stateless
  | @Name("aclList")
  | public class ACLListActionImpl implements ACLListAction {
  |     
  | 	@PersistenceContext
  | 	private EntityManager em;
  |    
  | 	@In 
  | 	private FacesMessages facesMessages;   
  |    
  | 	@Logger
  | 	private Log log;
  | 	
  | 	@SelectItems(labelMethod="getName", valueStrategy=SelectItems.Strategy.INDEX)
  | 	private List rights;
  | 	
  | 	@In(required=false)@Out(required=false)
  | 	private ARO selAro;
  | 	
  | 	/**************************************************************************
  | 	 * Get all right types.
  | 	 * @return
  | 	 */
  | 	@Factory("rights")
  | 	public List getRights() {
  | 		System.out.println("ACLListActionImpl:getRights()");
  | 		
  | 		// Only get the list once/request
  | 		if(rights == null){
  | 			rights = em.createQuery("from ARO").getResultList();
  | 			
  | 			selAro = (ARO)rights.get(0);
  | 		}
  |        return rights;
  | 	}
  | 	
  | 	@Factory("converter")
  | 	public Converter getConverter() {
  | 		System.out.println("ACLListImpl::getConverter()");
  | 		return new SelectItemsConverter() {
  | 			
  | 			@Override
  | 			protected Object convertToObject(FacesContext arg0, UIComponent arg1, String value) throws ConverterException {
  | 				log.info("AroConverter:getAsObject() :: " + value);
  | 				
  | 				ARO aro = null;
  | 				if ((value==null)||value.length()==0) {
  | 					throw new ConverterException("Error 1 !");
  | 				}
  | 		    
  | 				for (Iterator iter = em.createQuery("from ARO").getResultList().iterator(); iter.hasNext();) {
  | 					ARO a = (ARO) iter.next();
  | 					if(a.getName().equals(value)){
  | 						aro = a;
  | 						break;
  | 					}
  | 				}
  | 		    
  | 				// Sanity Check
  | 				if (aro==null) {
  | 					aro = new ARO();
  | 					aro.setAro_id(0);
  | 				}
  | 
  | 				log.info(aro);
  | 				return aro;
  | 			}
  | 
  | 			@Override
  | 			protected String convertToString(FacesContext arg0, UIComponent arg1, Object value) throws ConverterException {
  | 				System.out.println("AroConverter:convertToString() ::" + value);
  | 				if(value instanceof ARO){
  | 					return ((ARO)value).getName();
  | 				
  | 				}else if(value instanceof Long){
  | 					return ((Long)value).toString();
  | 				
  | 				}else if(value instanceof String){
  | 					return value.toString();
  | 				}
  | 				
  | 				return "";
  | 			}
  | 		};
  | 	}
  | }

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

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



More information about the jboss-user mailing list