• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Struts 1.3 - html:option doesn't select Integer value

 
Ranch Hand
Posts: 363
Firefox Browser Redhat Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Struts 1.3 for my application. I found that Struts is not 'selecting' a value if the value type is Integer in html:select and html: option. It's selecting if the type is String. Why? See the below code:


Where roleId is an Integer and roleName is String.

The web page displays:


As you can see, there is no 'selected' property for Integer values. Can someone explain why? What is the solution for this?

Many thanks in adv.!
 
author & internet detective
Posts: 42003
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your type and int or an Integer? If the later, can you try it with int? Struts was developed before autoboxing so it might not know what to do with mixed types.

A workaround of course would be to use String. Or to add an if statement in the JSP to set the selection.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic