[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-1326) Seam-CVS (as of May 15, 2007) breaks s:enumItem

Matthias Miraculix (JIRA) jira-events at lists.jboss.org
Tue May 29 06:39:10 EDT 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-1326?page=comments#action_12363356 ] 
            
Matthias Miraculix commented on JBSEAM-1326:
--------------------------------------------

Made my own EnumConverter-Impl. which does not rely on getExpectedType ... 
Don't know which drawback's this method has: 


<code>
public class EnumConverter implements Converter, StateHolder
{
	public static final String CONVERTER_ID = "com.my.common.jsf.converter.EnumConverter";
	private boolean istransient;
	private Class type;
	
	@SuppressWarnings("unchecked")
	public Object getAsObject(FacesContext context, UIComponent comp, String value) throws ConverterException {
		return Enum.valueOf(type, value);
	}

	public String getAsString(FacesContext context, UIComponent component, Object object) throws ConverterException {
		if (object == null) {
			return null;
		}
		this.type = ((Enum) object).getClass();
		return ((Enum) object).name();
	}

	public void restoreState(FacesContext arg0, Object state) {
		Object values[] = (Object[]) state;
		this.istransient = (Boolean) values[0];
		this.type = (Class<? extends Enum>) values [1];
	}

	public Object saveState(FacesContext arg0) {
		Object values[] = new Object[2];
		  values[0] = istransient;
		  values[1] = type;
		  return (values);
	}

	public void setTransient(boolean istransient) {
		this.istransient = istransient;
	}
	
	public boolean isTransient() {
		return istransient;
	}
}
</code>

> Seam-CVS (as of May 15, 2007) breaks s:enumItem
> -----------------------------------------------
>
>                 Key: JBSEAM-1326
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1326
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: JSF
>    Affects Versions: 1.3.0.ALPHA
>         Environment: JBoss 4.2.0CR2
> Seam-CVS build as of May 15, 2007
>            Reporter: Hung Tang
>         Assigned To: Pete Muir
>
> Did a build of seam-cvs recently and it breaks s:enumItem functionality in my webapp as well as the seam-pay example.  Brief exception here:
> Caused by: java.lang.IllegalArgumentException: java.lang.Object is not an enum type
>         at java.lang.Class.enumConstantDirectory(Class.java:2965)
>         at java.lang.Enum.valueOf(Enum.java:187)
>         at org.jboss.seam.ui.EnumConverter.getAsObject(EnumConverter.java:17)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list