0

Really odd one...

I have a converter which works when I use a p:SelectOneMenu, but when I switch to a p:SelectOneRadio, I get a major crash with a java heap space errors. The stacktrace seems to be of no use, just a java.lang.OutOfMemeoryError.

This works:

<p:selectOneMenu id="regions" value="#{aDMSBean.selectedRegion}">
    <f:selectItem itemLabel="Global" itemValue="#{null}" />
    <f:selectItems value="#{aDMSBean.adminRegions}" var="adminRegion" itemLabel="#  {adminRegion.regionName}" itemValue="#{adminRegion}" />                 
    <f:converter id="adminRegionConverter" converterId="regionConverter"  /> 
    <p:ajax listener="#{aDMSBean.regionSelect}" update="unassignedTasks"></p:ajax>                  
</p:selectOneMenu>  

This crashes and burns:

<p:selectOneRadio  id="regions" value="#{aDMSBean.selectedRegion}">
        <f:selectItem itemLabel="Global" itemValue="#{null}" />
        <f:selectItems value="#{aDMSBean.adminRegions}" var="adminRegion" itemLabel="#  {adminRegion.regionName}" itemValue="#{adminRegion}" />                 
        <f:converter id="adminRegionConverter" converterId="regionConverter"  /> 
        <p:ajax listener="#{aDMSBean.regionSelect}" update="unassignedTasks"></p:ajax>                  
    </p:selectOneRadio>

I can only assume the converter is OK, as it works with the selectOneMenu.

@FacesConverter("regionConverter")
public class RegionConverter  implements Converter  {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Region region = null;

        if (value != null && value.length() > 0) {
            region = Region.findRegion(new Long(value));
        }

        return region;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String val = "";
        if (value != null && value instanceof Region) {
            val = ((Region) value).getId().toString();
        }
        return val;
    }
}

Regards

i

smackenzie
  • 2,880
  • 7
  • 46
  • 99
  • Hi, In the end it was a recursive RooToString method being called. I had to examine the data model relationships and add an annotation to RooToString to avoid the cycle in a few entities RooToString(excludeFields = { "adminRegion" }) – smackenzie May 16 '13 at 15:35

1 Answers1

0

In the end it was a recursive @RooToString method being called. I had to examine the data model relationships and add an annotation to @RooToString to avoid the cycle in a few entities

@RooToString(excludeFields = { "adminRegion" })

smackenzie
  • 2,880
  • 7
  • 46
  • 99