using jsp:setProperty on non-simple types.  
Author Message
Emmanuel Doute





PostPosted: 2005-1-10 20:48:00 Top

java-programmer, using jsp:setProperty on non-simple types. Hi,

I'm currently having a small problem with my application. I'm using
some simple classes that wraps simple types to help me provide multiple
representation. For example, a DateCBO calls wraps the Date type and
gives me the oportunity to have various 'getters' like
getDateShortFormat(), getHtml(), getDateLongFormat() and so on.

My beans are using this kind of wrappers as their properties.

I have already made a custom tag to retrieve information that i use
instead of the standard jsp:getProperty
Now, i'm trying to use the jsp:setProperty to initialise the bean
property, but i have 'Could not coerce String to non-primitive type
StringCBO without bean property editor (JSP 1.2: 2.13.2.1) at line 13'
error.

Is there an interface that i can use to allow direct usage of
'jsp:setProperty', or should i create a custom tag as well.

thanks.

 
Ryan Stewart





PostPosted: 2005-1-11 20:37:00 Top

java-programmer >> using jsp:setProperty on non-simple types. "Emmanuel Doute" <email***@***.com> wrote in message
news:email***@***.com...
> Hi,
>
> I'm currently having a small problem with my application. I'm using
> some simple classes that wraps simple types to help me provide multiple
> representation. For example, a DateCBO calls wraps the Date type and
> gives me the oportunity to have various 'getters' like
> getDateShortFormat(), getHtml(), getDateLongFormat() and so on.
>
> My beans are using this kind of wrappers as their properties.
>
> I have already made a custom tag to retrieve information that i use
> instead of the standard jsp:getProperty
> Now, i'm trying to use the jsp:setProperty to initialise the bean
> property, but i have 'Could not coerce String to non-primitive type
> StringCBO without bean property editor (JSP 1.2: 2.13.2.1) at line 13'
> error.
>
> Is there an interface that i can use to allow direct usage of
> 'jsp:setProperty', or should i create a custom tag as well.
>
You could create a setter on your bean that accepts a String.


 
John C. Bollinger





PostPosted: 2005-1-11 22:20:00 Top

java-programmer >> using jsp:setProperty on non-simple types. Emmanuel Doute wrote:

> Hi,
>
> I'm currently having a small problem with my application. I'm using
> some simple classes that wraps simple types to help me provide multiple
> representation. For example, a DateCBO calls wraps the Date type and
> gives me the oportunity to have various 'getters' like
> getDateShortFormat(), getHtml(), getDateLongFormat() and so on.
>
> My beans are using this kind of wrappers as their properties.
>
> I have already made a custom tag to retrieve information that i use
> instead of the standard jsp:getProperty
> Now, i'm trying to use the jsp:setProperty to initialise the bean
> property, but i have 'Could not coerce String to non-primitive type
> StringCBO without bean property editor (JSP 1.2: 2.13.2.1) at line 13'
> error.
>
> Is there an interface that i can use to allow direct usage of
> 'jsp:setProperty', or should i create a custom tag as well.

You can do as the message suggests and create a property editor for that
bean property, but it is probably at least as much work as writing a
custom tag to do the job. If you prefer, you could write a bit of
scriptlet code to do the job, or if you are using JSP 2 you could do it
with JSP expression language.


John Bollinger
email***@***.com
 
 
Emmanuel Doute





PostPosted: 2005-1-12 0:06:00 Top

java-programmer >> using jsp:setProperty on non-simple types. Thanks for your answers.

I will probably use a scriptlet, as i seldom have to set property from
within the JSP.

I tried to add just a setter method with a String, but it still
complains.

It finally worked by adding a 'real' String property and using it's
setter to update my non-basic property as well. But this is causing
quite a mess in all the bean properties, so i gave it up.

 
 
Ryan Stewart





PostPosted: 2005-1-12 5:51:00 Top

java-programmer >> using jsp:setProperty on non-simple types. "Emmanuel Doute" <email***@***.com> wrote in message
news:email***@***.com...
> Thanks for your answers.
>
> I will probably use a scriptlet, as i seldom have to set property from
> within the JSP.
>
> I tried to add just a setter method with a String, but it still
> complains.
>
> It finally worked by adding a 'real' String property and using it's
> setter to update my non-basic property as well. But this is causing
> quite a mess in all the bean properties, so i gave it up.
>
It shouldn't be all that messy:

public class SomeBean {
private String value;
// Other properties

public void setValue(String value) {
this.value = value;
this.parse();
}

private void parse() {
// Do stuff to populate from the String whatever properties you need
}

// Other methods
}