• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp:setProperty param

 
janne jounivich
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Wondering about the following. If bean's property happens to be int, not String, and I want to set the value by using jsp:setProperty .. param, is it automatically converted from String into int?

Bean
class Friend html: form input="text" name="userAge" /form
int getAge()
setAge(int age)

jsp: to set
jsp:setProperty name="friend" property="age" param="userAge"
to print
jsp:getProperty name="friend" property="age"

Thanx
 
Mike Pandey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi janne

Yes..the type coercion happens automatically for all the primitives.

But if u use <B> request time expression(<%= %> <?B> the same won't work...With EL this shud do fine
 
janne jounivich
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Mike,

For some very odd reason, the coercing didn't work with IE this morning but now testing it again, automatic conversion seems to be working as it should.

It is just easier for me to memorize all the tricky details when going thru HFS and preparing for the cert when I test the examples in real environment and put the knowledge into practice.

Cheers,
J
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic