You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Matthias Heinrich (JIRA)" <de...@myfaces.apache.org> on 2009/06/25 12:19:07 UTC
[jira] Created: (TRINIDAD-1518) selectOneChoice and selectOneList
don't bind correct or as expected if an converter is used
selectOneChoice and selectOneList don't bind correct or as expected if an converter is used
-------------------------------------------------------------------------------------------
Key: TRINIDAD-1518
URL: https://issues.apache.org/jira/browse/TRINIDAD-1518
Project: MyFaces Trinidad
Issue Type: Bug
Affects Versions: 1.2.11-core
Environment: java 6u13
tomcat 6.0.16
myfaces-api-1.2.6
myfaces-impl-1.2.6
trinidad-api-1.2.11
trinidad-impl-1.2.11
spring-web-2.5.6
Reporter: Matthias Heinrich
On rendering an <tr:selectOneChoice> Listing 1 i got this warning:
#25.06.2009 11:14:39 org.apache.myfaces.trinidadinternal.renderkit.core.xhtml.SimpleSelectOneRenderer _getSelectedIndex
#WARNUNG: Es konnte kein ausgewähltes Element gefunden werden, das mit dem Wert "2" in CoreSelectOneChoice[UIXEditableFacesBeanImpl, id=j_id25] übereinstimmt
So if the site is rendered the selection isn't correct .
Listing 1 the .jspx file
<pre>
<tr:selectOneChoice autoSubmit="true" converter="#{locationConverterBean}"
label="#{labels.location}" required="true"
unselectedLabel=" " value="#{singleItemBean.inventoryItem.location}"
valueChangeListener="#{singleItemBean.processLocationChanged}">
<f:selectItems value="#{locationBean.locationItems}" />
</tr:selectOneChoice>
</pre>
Listing 2 the converter Bean:
public class LocationConverter implements Converter
{
@Autowired
LocationService locationService;
public LocationConverter(){ }
public LocationConverter(LocationService locationService)
{
this.locationService = locationService;
}
@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) throws ConverterException
{
if(value == null)
return null;
else if(value.isEmpty() || value.equals("-1"))
return null;
else
{
try
{
return locationService.getLocationById(Long.parseLong(value));
}
catch (ServiceLayerException e)
{
// TODO: handle exception
throw new ConverterException(new FacesMessage(e.getLocalizedMessage()));
}
}
}
@Override
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException
{
if(value == null)
return null;
else if(value instanceof Location)
return Long.toString(((Location)value).getId());
else if(value instanceof String)
return (String)value;
else if(value instanceof Long)
return ((Long)value).toString();
else if(value instanceof Integer)
return ((Integer)value).toString();
else
{
throw new ConverterException(new FacesMessage("LocationConverter: wrong Type"));
}
}
}
It seems that the Converrter isn't called an the rendering phase.
It also seems like the issue reported from Fred Davis see here http://www.mail-archive.com/users@myfaces.apache.org/msg52354.html.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.