the null pointer exception comes from :
at org.apache.tapestry5.internal.util.SelectModelRenderer.
option(SelectModelRenderer.java:51)


which is, in the code of tapestry this :
 @SuppressWarnings("unchecked")
    public void option(OptionModel optionModel)
    {
        Object optionValue = optionModel.getValue();

       * String clientValue = encoder.toClient(optionValue);   <--- line 51*

        writer.element("option", "value", clientValue);

        if (isOptionSelected(optionModel, clientValue))
writer.attributes("selected", "selected");

        writeDisabled(optionModel.isDisabled());
        writeAttributes(optionModel.getAttributes());

        writer.write(optionModel.getLabel());

        writer.end();
    }



So in this line it should execute the toClient method of my ValueEncoder so
I added some system.out.println in it just to see if it really does it :
public class TypeClientDtoEncoder implements ValueEncoder<TypeClientDto>,
ValueEncoderFactory<TypeClientDto> {

@Inject
private IServiceTypeClient serviceTypeClient;

/*
 * (non-Javadoc)
 *
 * @see org.apache.tapestry5.ValueEncoder#toClient(java.lang.Object)
 */
@Override
public String toClient(TypeClientDto value) {
// return the given object's ID
*System.out.println("abcdef");*
* System.out.println("encoder typeclient toclient");*
return String.valueOf(value.getId());
}

/*
 * (non-Javadoc)
 *
 * @see org.apache.tapestry5.ValueEncoder#toValue(java.lang.String)
 */
@Override
public TypeClientDto toValue(String clientValue) {
// find the typeclientdto object of the given ID in the database
System.out.println("abcdef");
System.out.println("encoder typeclient tovalue");
return serviceTypeClient.findTypeClientDto(Long.parseLong(clientValue));
}

// let this ValueEncoder also serve as a ValueEncoderFactory
/*
 * (non-Javadoc)
 *
 * @see
 * org.apache.tapestry5.services.ValueEncoderFactory#create(java.lang.Class)
 */
@Override
public ValueEncoder<TypeClientDto> create(Class<TypeClientDto> type) {
return this;
}

}



But nothing appears in the console, so the problem is here, why it doesn't
pass in the method toClient of my ValueEncoder ?


2014-07-15 11:28 GMT+02:00 Geoff Callender <
geoff.callender.jumpst...@gmail.com>:

> If I read Bob right, I think Bob said his problem was not due to nulls, it
> was due to the selected value not being one of the values in the
> OptionModel.
>
> It might also be worth trying secure="literal:false" on the Select.
>
> On 15 Jul 2014, at 5:59 pm, squallmat . <squall...@gmail.com> wrote:
>
> > I tried to see what was in my selectmodel after the factory loading with
> > this code :
> >
> > // initialize selectmodels
> > selectType = selectModelFactory.create(typeClientList, "nomType");
> >
> > List<OptionModel> optionModelList = selectType.getOptions();
> >
> > System.out.println("begin");
> > for (OptionModel optionModel : optionModelList) {
> > System.out.println(optionModel.getLabel());
> > System.out.println(optionModel.getValue());
> > }
> > System.out.println("end");
> >
> >
> > And in the console I see that I have exactly what I want and I don't see
> > any Null in my selectmodel.
> >
> >
> > @Bob : How do you resolved your problem ?
> >
> >
> > Anyone alse to help me on this ? I'm stuck on thsi problem :(
> >
> >
> > 2014-07-14 20:21 GMT+02:00 Bob Harner <bobhar...@gmail.com>:
> >
> >> I haven't read through this thread very carefully, but last week I got
> >> a nearly identical stack trace. It was from Palette, not Select, but
> >> those components have a lot of identical code. In my case the problem
> >> was that the SelectModel had all of the expected values *except* the
> >> selected value. Tapestry didn't do a good job with the error messages
> >> in that case.
> >>
> >> On Fri, Jul 11, 2014 at 5:36 AM, squallmat . <squall...@gmail.com>
> wrote:
> >>> When I do this :
> >>>
> >>> selectType = selectModelFactory.create(typeClientList, "nomType");
> >>> selectApplications = selectModelFactory.create(applicatifList, "nom");
> >>>
> >>> each lists (typeClientList and applicatifList) are not empty.
> >>>
> >>> And for the second parameter, I put the variable name of a String of an
> >>> object contained in the list, is this what have to be done ?
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> 2014-07-10 16:57 GMT+02:00 Thiago H de Paula Figueiredo <
> >> thiag...@gmail.com>
> >>> :
> >>>
> >>>> On Thu, 10 Jul 2014 09:51:08 -0300, squallmat . <squall...@gmail.com>
> >>>> wrote:
> >>>>
> >>>> Caused by: java.lang.NullPointerException
> >>>>> at
> >>>>> org.apache.tapestry5.internal.util.SelectModelRenderer.
> >>>>> option(SelectModelRenderer.java:51)
> >>>>>
> >>>>
> >>>> Check whether you passed a null OptionModel to the SelectionModel.
> >>>>
> >>>> --
> >>>> Thiago H. de Paula Figueiredo
> >>>> Tapestry, Java and Hibernate consultant and developer
> >>>> http://machina.com.br
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >>>> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>>>
> >>>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> >> For additional commands, e-mail: users-h...@tapestry.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to