Problem whith SelectOneMenu - selected
gazadonf Mar 26, 2008 12:32 PMHi all.
I have a problem with <f:selectOneMenu> when i have a selected value, it is never selected in my page.
Here is my page code:
<s:decorate id="typeMouvement" template="../../layout/edit.xhtml">
<ui:define name="selectOneMenu">
<h:selectOneMenu id="listTypeMouvement" value="#{ecr_cta_1.myNaturePiece}" converter="#{ecr_cta_1.natureConverter}" rendered="#{ecr_cta_1.editMode}" required="#{ecr_cta_1.editMode}">
<f:selectItem itemLabel=""/>
<f:selectItems value="#{ecr_cta_1.natureConverter.content}"/>
</h:selectOneMenu>
</ui:define>
</s:decorate>
Here is my converterFacory code:
public MapConverter getConverter(IrCompagnie myCompagnie, final String theConvertedClassName)
throws ConverterException
{
MapConverter theConverter = null;
try
{
theConverter = converterFactory.getConverter(myCompagnie, theConvertedClassName);
}here is the code of the MapConverter class
public class MapConverter implements Converter
{
@Logger
Log log = Logging.getLog(MapConverter.class);
/** The content. */
private final Map<String, DatabaseObject> content;
/**
* Gets the content.
*
* @return the content
*/
public Map<String, DatabaseObject> getContent()
{
return content;
}
/**
* Instantiate a new map converter.
*
* @param content
* the content
*/
public MapConverter(final Map<String, DatabaseObject> content)
{
super();
this.content = content;
}
/**
* return the objet's key.
*
* @param object
* the object
*
* @return the key as string
*/
private String getAsString(final DatabaseObject object)
{
String key = null;
for (final Map.Entry<String, DatabaseObject> theEntry : content.entrySet())
{
log.debug("=====================>> theEntry.key #0", theEntry.getKey());
if (theEntry.getValue().equals(object))
{
key = theEntry.getKey();
break;
}
}
return key;
}
/**
* return the object
*
* @param key
* the key
*
* @return the object
*/
private DatabaseObject getAsObject(final String key)
{
return content.get(key);
}
/*
* (non-Javadoc)
*
* @see javax.faces.convert.Converter#getAsObject(javax.faces.context.FacesContext, javax.faces.component.UIComponent,
* java.lang.String)
*/
public Object getAsObject(final FacesContext arg0, final UIComponent arg1, final String arg2)
{
return getAsObject(arg2);
}
/*
* (non-Javadoc)
*
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent,
* java.lang.Object)
*/
public String getAsString(final FacesContext arg0, final UIComponent arg1, final Object arg2)
{
String retour = null;
if (arg2 instanceof DatabaseObject)
{
retour = getAsString((DatabaseObject)arg2);
}
return retour;
}
public void setLog(final Log log)
{
this.log = log;
}
}My selectItems are all dispayed what ever i have in the vlaue field, it is never selected when i display my page.
What's wrong with my code???