Hi!
I use 
Tomcat 6
myFaces 1.2.2
tomahawk 1.1.6

I tried do create a Converter for following model:


public class PlanningPoint {
        private String country;
        private String location;
        private String street;
        private String postCode;
        private String houseNumber;
        private String identifier;

        public PlanningPoint(final String country, final String location, final
String street,
                        final String postCode, final String houseNumber) {
                super();
                this.country = country;
                this.location = location;
                this.street = street;
                this.postCode = postCode;
                this.houseNumber = houseNumber;
        }

        public PlanningPoint() {
        }

        public String toString() {
                return this.country + ";" + this.location + ";" + this.street + 
";" +
this.postCode + ";"
                        + this.houseNumber + ";" + this.identifier;
        }

        public String getCountry() {
                return this.country;
        }

        public void setCountry(final String country) {
                this.country = country;
        }

        public String getLocation() {
                return this.location;
        }

        public void setLocation(final String location) {
                this.location = location;
        }

        public String getStreet() {
                return this.street;
        }

        public void setStreet(final String street) {
                this.street = street;
        }

        public String getPostCode() {
                return this.postCode;
        }

        public void setPostCode(final String postCode) {
                this.postCode = postCode;
        }

        public String getHouseNumber() {
                return this.houseNumber;
        }

        public void setHouseNumber(final String houseNumber) {
                this.houseNumber = houseNumber;
        }

        public String getIdentifier() {
                return this.identifier;
        }

        public void setIdentifier(final String identifier) {
                this.identifier = identifier;
        }
}


Thats the converter:

public class PlanningPointConverter implements Converter {

        public Object getAsObject(final FacesContext context, final  UIComponent
component, final String value) {
                if (value == null) {
                        return new PlanningPoint();
                } else if (value.isEmpty()) {
                        return new PlanningPoint();
                }
                PlanningPoint p = new PlanningPoint();
                try {
                    String [] pComps = StringUtility.split(value, ";");
                    p.setCountry(pComps[0]);
                    p.setLocation(pComps[1]);
                    p.setStreet(pComps[2]);
                    p.setPostCode(pComps[3]);
                    p.setHouseNumber(pComps[4]);
                    p.setIdentifier(pComps[5]);
                } catch (ConverterException e) {
                        e.printStackTrace();
                }
            return p;
        }       

        public String getAsString(final FacesContext context, final  UIComponent
component, final Object value) {
                if (value.equals("") || value == null) {
                        return "";
                } else {
                        
                }
                PlanningPoint p = (PlanningPoint) value;
                String s = "";
                try {
                        s = ((PlanningPoint) value).toString();         
                } catch (ConverterException e) {
                        e.printStackTrace();
                }
                return s;
        }       
}


jsp snippet:

<h:panelGrid id="planningPG5" columns="2" border="1">
                        <h:outputText value="#{labels.planStartDropdown}"
                                styleClass="outputText"
                                
rendered="#{planningContrl.renderGeoDropDownStart}" />
                        <h:selectOneMenu id="planGeoDropdown1"
                                
value="#{planningContrl.geoStartDropDownSelected}"
                                
rendered="#{planningContrl.renderGeoDropDownStart}">
                                <f:converter 
converterId="planningPointConverter" />
                                <f:selectItems 
value="#{planningContrl.geoStartDropDownList}" />
                        </h:selectOneMenu>
                        <h:outputText value="#{labels.planEndDropdown}"
                                styleClass="outputText"
                                
rendered="#{planningContrl.renderGeoDropDownEnd}" />
                        <h:selectOneMenu id="planGeoDropdown2"
                                
value="#{planningContrl.geoEndtDropDownSelected}"
                                
rendered="#{planningContrl.renderGeoDropDownEnd}">
                                <f:converter 
converterId="planningPointConverter" />
                                <f:selectItems 
value="#{planningContrl.geoEndDropDownList}" />
                        </h:selectOneMenu>
                </h:panelGrid>


controller snippet:

public class PlanningController {
        private boolean renderGeoDropDownStart;
        private boolean renderGeoDropDownEnd;
        private List<SelectItem> geoEndDropDownList;
        private PlanningPoint geoEndtDropDownSelected;
        private List<SelectItem> geoStartDropDownList;
        private PlanningPoint geoStartDropDownSelected;

public void geocodeStart(final ActionEvent event) {
                try {
                        this.setDropDownGeo(this.model.geocode(this.startPoint),
PlanningController.DropDown.GEO_START);
                        this.startPoint = new PlanningPoint();
                        this.renderGeoDropDownStart = true;
                } catch (WebserviceException e) {
                        UIComponent component =
ComponentSupport.getComponentById("subViewPlanning:fPlanning");
                        ComponentSupport.showMessageFromBundle(component, 
"errorMsgWebservice");
                }
        }

        public void geocodeEnd(final ActionEvent event) {
                try {
                        this.setDropDownGeo(this.model.geocode(this.endPoint),
PlanningController.DropDown.GEO_END);
                        this.endPoint = new PlanningPoint();
                        this.renderGeoDropDownEnd = true;
                } catch (WebserviceException e) {
                        UIComponent component =
ComponentSupport.getComponentById("subViewPlanning:fPlanning");
                        ComponentSupport.showMessageFromBundle(component, 
"errorMsgWebservice");
                }
        }

        private void setDropDownGeo(final List<PlanningPoint> l, final DropDown 
d)
{
                List<SelectItem> tmpList = new LinkedList<SelectItem>();
                tmpList.add(new SelectItem(""));
                for (PlanningPoint p : l) {
                        this.geoStartDropDownSelected = p;
                        tmpList.add(new SelectItem(p, p.getIdentifier()));
                }               
                switch (d) {
                case GEO_START:
                        this.geoStartDropDownList.addAll(tmpList);              
                                
                        break;
                case GEO_END:
                        this.geoEndDropDownList.addAll(tmpList);                
                                
                        break;
                default:
                        break;
                }
        }

        public List<SelectItem> getGeoEndDropDownList() {
                return this.geoEndDropDownList;
        }

        public void setGeoEndDropDownList(final List<SelectItem>
geoEndDropDownList) {
                this.geoEndDropDownList = geoEndDropDownList;
        }

        public PlanningPoint getGeoEndtDropDownSelected() {
                return this.geoEndtDropDownSelected;
        }

        public void setGeoEndtDropDownSelected(final PlanningPoint
geoEndtDropDownSelected) {
                this.geoEndtDropDownSelected = geoEndtDropDownSelected;
        }

        public List<SelectItem> getGeoStartDropDownList() {
                return this.geoStartDropDownList;
        }

        public void setGeoStartDropDownList(final List<SelectItem>
geoStartDropDownList) {
                this.geoStartDropDownList = geoStartDropDownList;
        }

        public PlanningPoint getGeoStartDropDownSelected() {
                return this.geoStartDropDownSelected;
        }

        public void setGeoStartDropDownSelected(final PlanningPoint
geoStartDropDownSelected) {
                this.geoStartDropDownSelected = geoStartDropDownSelected;
        }

        public boolean isRenderGeoDropDownStart() {
                return this.renderGeoDropDownStart;
        }

        public void setRenderGeoDropDownStart(final boolean 
renderGeoDropDownStart)
{
                this.renderGeoDropDownStart = renderGeoDropDownStart;
        }

        public boolean isRenderGeoDropDownEnd() {
                return this.renderGeoDropDownEnd;
        }

        public void setRenderGeoDropDownEnd(final boolean renderGeoDropDownEnd) 
{
                this.renderGeoDropDownEnd = renderGeoDropDownEnd;
        }
}


If I tried out this at the first (meaning loading values from one of the
renderGeoDropDownStart)  all work correctly but if I reload
renderGeoDropDownStart nothing occur - That means no CommandButton works or
the reloading is completed.

Faces Traces says:
Request Lifecycle:
Restore View (GREEN) --->       Apply Request (GREEN) --->      Validations 
(RED =
ERROR) ---> Update Model (GREY) --> Application (GREY) ---> Response (GREEN)

ERROR MESSAGES 
Component ID: subViewPlanning:fPlanning:planGeoDropdown1 
Severity: ERROR 
Message: subViewPlanning:fPlanning:planGeoDropdown1: Validierungsfehler:
Wert ist keine gültige Auswahl
(in english I think thats mean: validation error: value is not a valid
option)

someone know whats going wrong?

best regards
-- 
View this message in context: 
http://www.nabble.com/myFaces-1.2---Converter-Problem-tp15806504p15806504.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.

Reply via email to