You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Ali Abdel-Aziz Ali <ro...@gmail.com> on 2008/03/26 12:33:39 UTC

Fwd: Converter strange behaviour

Hi All,

I have strange behavior in my Custom Converter

I have created new Converter called LongConverter and I have registered it
in faces-Config.xml
and I have used it inside selectOneMenu component as follows

<t:saveState value="#{applicationAddBean.selectedId}" />

                         <t:selectOneMenu id="applicationTypes"
                                             value="#{
applicationAddBean.selectedId}"
                                             onchange="submit();">
                                <f:selectItem itemLabel="#{
globalResource.selectItemLabel}"
                                              itemValue="#{
globalResource.selectItemValue}"/>
                                <t:selectItems value="#{
applicationAddBean.procedures}"
                                                      var="procedureVersion"

                                                      itemLabel="#{
procedureVersion.versionName}"
                                                      itemValue="#{
procedureVersion.id}" />
                                <f:converter converterId="LongConverter" />
                            </t:selectOneMenu>


but when I select an item it first call the setSelectedId(Long id) which
passes null to it; then it call getAsObject method inside LongConverter
class

                        public Object getAsObject(FacesContext facesContext,

                                                               UIComponent
uIComponent,
                                                               String
string) throws ConverterException {
                                 return Long.valueOf(string);
                        }


and when I remove the save state line it didn't fire the setSelectedId
method at all just inoke the getAsObject method

Can any body help?


Thanks in advance.

-- 
Ali Abdel-Aziz
http://www.aliabdelaziz.com