This discussion is archived
2 Replies Latest reply: Mar 25, 2013 10:10 AM by malky RSS

issues passing dropdown value back to java

malky Explorer
Currently Being Moderated
I have a bunch of select tags in my page where some of them allows the user to use the dropdown and some of them will be disabled at a given time. so I have a select tag in my jsp such as:

<html:select name="myobject" property="myfield" disabled="$(isDisabled ? 'disabled' : '')"/>

I wanted to set as readonly a select tag on my jsp but apparently is not possible so I had to put disable. Since disabled values are not passed back to the application when a user submits the action I created a hidden object of it to pass it as it's suggested everywhere to work around that...

<html:hidden name="myobject" property="myfield" indexed="true"/>

The problem is.. when the form is submited I don't get the new dropdown value selected by the user, I debug into my java code and what I receive is the value that was originally sent to the page instead of what the user picked. It works if I removed the hidden field but if I do so then the disabled selections won't displayed when refreshed cause disabled fields don't pass back the values and i'll receive null at my end... how do I fix this problem?

Thanks,
  • 1. Re: issues passing dropdown value back to java
    gimbal2 Guru
    Currently Being Moderated
    You fail:

    a) to mention this is struts related; quite important information wouldn't you think? Or were you assuming that the entire Java world is using Struts?
    b) which version of struts you're using
    c) to realize that this is not a struts forum; struts is an Apache product, not an Oracle product

    Try a google for "struts readonly", you're not the first person to run into issues like this. For better help sooner, find a struts forum (or stackoverflow if there is nothing specific). That is for your own benefit, in such a place you find lots of people actually using the framework. Here only a couple if you're lucky. This forum is for Oracle products, which boils down to Servlets, JSPs and Javaserver Faces.
  • 2. Re: issues passing dropdown value back to java
    malky Explorer
    Currently Being Moderated
    gimbal2: You're extremely rude in your response, so I'll respond in an equal manner:

    Why would I goodle "struts readonly", ? seems like you didn't even understand the question, staroverflow done even before coming here, so don't assume i just decided to randomly post to the first forum i found.

    a) The tag is not my main issue, heck, give me a JSP tag that can read-only a select? no, right?... look online, doesn't seem possible no matter what tag you look, that's not a struts issue, it's a very general issue. Disable has to be done and disable won't be passed back to JAVA no matter what framwork you use.. if you see HTML specification at http://www.w3.org/TR/html401/interact/forms.html#h-17.6, select has not readonly (just disabled, but you can't use it for submit value).
    I'm debugging from the browser itself the value in the form so it's not a matter of how strusts passes values back and forth because the value in itself because it's set before even clicking submit.

    b) doesn't seem relevant anymore from your point (c)

    c) to realize that you should not open your mouth unless you have something useful to say in a HELP forum.

    Since apparently I cannot ask JSP (which.. oh wait.. it is Java) questions if I'm using struts then I guess i'll move to another place... if someone would be kind enough to suggest another way to do it or knows how to solve this issue in another way, I'd be greatful.

    Thanks,

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points