You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Cagatay Civici <ca...@gmail.com> on 2006/12/05 20:06:12 UTC

Re: sandbox selectItems component

Hi,

It's fixed, thanks for reporting.

http://issues.apache.org/jira/browse/TOMAHAWK-817

Regards,

Cagatay

On 12/5/06, Gerald Müllan <bi...@gmail.com> wrote:
>
> The common way is to open a corresponding jira issue and apply the
> patch to it as an attachement.
>
> As a recent example see:
>
> http://issues.apache.org/jira/browse/TOMAHAWK-813
>
> cheers,
>
> Gerald
>
> On 12/5/06, Nacho Estrada <na...@gmail.com> wrote:
> > Where I should provide the patch?
> >
> > On 12/5/06, Gerald Müllan <bi...@gmail.com> wrote:
> > > Hi,
> > >
> > > well, the NullPointerException should steem from the fact that the
> > > core loadBundle gets its
> > > values only in rendering phase and not in every phase of the
> lifecycle.
> > >
> > > You can use s:loadBundle which makes sure that the bundle is evaluated
> > > in each phase.
> > > This should avoid that the label equals null.
> > >
> > > If you make any enhancements to s:selectItems it would be cool if you
> > > could also provide a patch for it. I am sure, cagatay appreciates it
> > > and will commit the stuff.
> > >
> > > cheers,
> > >
> > > Gerald
> > >
> > > On 12/5/06, Nacho Estrada <na...@gmail.com> wrote:
> > > > Hi devs,
> > > >
> > > > The next code in org.apache.myfaces.custom.selectitems.UISelectItems
> > > > is throwing a NullPointerException when label is null:
> > > >
> > > > private SelectItem createSelectItem() {
> > > >                 Object value = getItemValue();
> > > >                 String label = getItemLabel() != null ?
> getItemLabel().toString() : null;
> > > >                 SelectItem item = new SelectItem(value, label);
> > > >                 return item;
> > > > }
> > > >
> > > > The SelectItem constructor invoked has the following code:
> > > >
> > > >     public SelectItem(Object value, String label)
> > > >     {
> > > >         if (value == null) throw new NullPointerException("value");
> > > >         if (label == null) throw new NullPointerException("label");
> > > >         _value = value;
> > > >         _label = label;
> > > >         _description = null;
> > > >         _disabled = false;
> > > >     }
> > > >
> > > >
> > > > I've tried to change the createSelectItem method for this:
> > > >         private SelectItem createSelectItem() {
> > > >                 Object value = getItemValue();
> > > >                 SelectItem item;
> > > >                 if ( getItemLabel() != null )
> > > >                         item = new SelectItem(value,
> getItemLabel().toString());
> > > >                 else
> > > >                         item = new SelectItem(value);
> > > >                 return item;
> > > >         }
> > > > and everything works fine.
> > > >
> > > >
> > > > There's other problem and it's why I'm getting a null label.
> > > > This is my selectItems element:
> > > > <s:selectItems value="#{EmployeeMB.enumValues}" var="mia"
> > > >                                    itemValue="#{mia.value}"
> > > >         itemLabel="#{bundle[mia.value]}" />
> > > >
> > > > I have declared a loadBundle element:
> > > > <f:loadBundle basename="
> es.dbs.ysf.sampleapp.employee.view.EmployeeViewResources"
> > > > var="bundle"/>
> > > > I have my items in a String Collection and I use this bundle for
> > > > getting the labels.
> > > > Everything is rendered ok, but when I submit the form the system is
> > > > creating a SelectItem component and when evaluate the getItemLabel
> > > > method y get a null value. If I don't use the bundle for the labels
> > > > works perfectly.
> > > >
> > > > Comments are welcome. Thanks.
> > > >
> > > > StackTrace:
> > > > java.lang.NullPointerException: label
> > > >         at javax.faces.model.SelectItem.<init>(SelectItem.java:52)
> > > >         at
> org.apache.myfaces.custom.selectitems.UISelectItems.createSelectItem(
> UISelectItems.java:136)
> > > >         at
> org.apache.myfaces.custom.selectitems.UISelectItems.createSelectItems(
> UISelectItems.java:112)
> > > >         at
> org.apache.myfaces.custom.selectitems.UISelectItems.getValue(
> UISelectItems.java:90)
> > > >         at javax.faces.component._SelectItemsIterator.hasNext
> (_SelectItemsIterator.java:92)
> > > >         at javax.faces.component._SelectItemsUtil.matchValue
> (_SelectItemsUtil.java:46)
> > > >         at javax.faces.component.UISelectOne.validateValue(
> UISelectOne.java:62)
> > > >         at javax.faces.component.UIInput.validate(UIInput.java:353)
> > > >         at javax.faces.component.UIInput.processValidators(
> UIInput.java:183)
> > > >         at javax.faces.component.UIForm.processValidators(
> UIForm.java:70)
> > > >         at javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java:624)
> > > >         at javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java:624)
> > > >         at javax.faces.component.UIComponentBase.processValidators(
> UIComponentBase.java:624)
> > > >         at javax.faces.component.UIViewRoot.processValidators(
> UIViewRoot.java:146)
> > > >         at
> org.apache.myfaces.lifecycle.LifecycleImpl.processValidations(
> LifecycleImpl.java:262)
> > > >         at org.apache.myfaces.lifecycle.LifecycleImpl.execute(
> LifecycleImpl.java:76)
> > > >         at javax.faces.webapp.FacesServlet.service(FacesServlet.java
> :137)
> > > >         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:252)
> > > >         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:173)
> > > >         at
> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(
> ExtensionsFilter.java:190)
> > > >         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:202)
> > > >         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:173)
> > > >         at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
> ReplyHeaderFilter.java:96)
> > > >         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
> ApplicationFilterChain.java:202)
> > > >         at org.apache.catalina.core.ApplicationFilterChain.doFilter(
> ApplicationFilterChain.java:173)
> > > >         at org.apache.catalina.core.StandardWrapperValve.invoke(
> StandardWrapperValve.java:213)
> > > >         at org.apache.catalina.core.StandardContextValve.invoke(
> StandardContextValve.java:178)
> > > >         at
> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(
> SecurityAssociationValve.java:175)
> > > >         at org.jboss.web.tomcat.security.JaccContextValve.invoke(
> JaccContextValve.java:74)
> > > >         at org.apache.catalina.core.StandardHostValve.invoke(
> StandardHostValve.java:126)
> > > >         at org.apache.catalina.valves.ErrorReportValve.invoke(
> ErrorReportValve.java:105)
> > > >         at org.apache.catalina.core.StandardEngineValve.invoke(
> StandardEngineValve.java:107)
> > > >         at org.apache.catalina.connector.CoyoteAdapter.service(
> CoyoteAdapter.java:148)
> > > >         at org.apache.coyote.http11.Http11Processor.process(
> Http11Processor.java:869)
> > > >         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection
> (Http11BaseProtocol.java:664)
> > > >         at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(
> PoolTcpEndpoint.java:527)
> > > >         at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(
> MasterSlaveWorkerThread.java:112)
> > > >         at java.lang.Thread.run(Unknown Source)
> > > >
> > >
> > >
> > > --
> > > http://www.irian.at
> > >
> > > Your JSF powerhouse -
> > > JSF Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache MyFaces
> > >
> >
>
>
> --
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>