You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by John Menke <jm...@basebeans.com> on 2002/12/22 21:01:42 UTC

OptionsCollection and default value

I have searched the archives and can't find a direct answer to this:

I am using html:optionsCollection within an  html:select tag.

My form bean has a method getTaskCodeTypeOptions that returns a collection
of beans with name and value properties

and my JSP is coded as follows:

<html:select property="taskCodeType"><html:optionsCollection
property="taskCodeTypeOptions"  /></html:select>


MY JSP WILL RUN AND POPULATE THE SELECT TAG CORRECTLY, BUT IT DOESN'T CHOOSE
THE CORRECT INITIAL VALUE.

IE. THE "SELECTED" property is not set correctly.


Does anybody have this working?

-jm


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OptionsCollection and default value

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "John" == John Menke <jm...@basebeans.com> writes:

    John> I have searched the archives and can't find a direct answer to this:
    John> I am using html:optionsCollection within an  html:select tag.

    John> My form bean has a method getTaskCodeTypeOptions that returns a collection
    John> of beans with name and value properties

    John> and my JSP is coded as follows:

    John> <html:select property="taskCodeType"><html:optionsCollection
    John> property="taskCodeTypeOptions"  /></html:select>

    John> MY JSP WILL RUN AND POPULATE THE SELECT TAG CORRECTLY, BUT IT DOESN'T CHOOSE
    John> THE CORRECT INITIAL VALUE.

    John> IE. THE "SELECTED" property is not set correctly.

Do you have a getter/setter for the "taskCodeType" property on your bean?

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: OptionsCollection and default value

Posted by John Menke <jm...@basebeans.com>.

> Actually first just to appease me/us do a bean:write
> property="taskCodeType" right before you do the select options
> portion in your jsp. Then also view source of the page and see what
> you have listed as the values of the options (maybe your values aren't
> matching what is displayed, assuming you aren't using the label as the
> value of course). Let me know how it turns out.
>


Rick,


<td>Task Code Type
      <input type="text" name="taskCodeType" size="30" value="D
">
      <select name="taskCodeType"><option value="I">Internal</option>
<option value="C1">Client1</option>
<option value="C2">Client2</option>
<option value="D">Development</option></select></td>

It appears that I have the taskCodeType defined as char(15) in my
database --- that's why the value
is D(14 spaces)....

I need to either make the values column char(15) or switch taskCodeType to
be a varchar.

Thanks for your help!

-jm



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OptionsCollection and default value

Posted by Rick Reumann <ma...@reumann.net>.
On Sun, 22 Dec 2002 18:39:05 -0500
"John Menke" <jm...@basebeans.com> wrote:
 
> 
> I have to get JSP debugging setup to do that.  Do you know if eclipse
> supports
> JSP debugging with Tomcat?
> 
Actually first just to appease me/us do a bean:write
property="taskCodeType" right before you do the select options
portion in your jsp. Then also view source of the page and see what
you have listed as the values of the options (maybe your values aren't
matching what is displayed, assuming you aren't using the label as the
value of course). Let me know how it turns out.


-- 
Rick

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OptionsCollection and default value

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "John" == John Menke <jm...@basebeans.com> writes:

    >> At this point, I would be executing this in the debugger, and
    >> tracing through
    >> the SelectTag code, and your form bean code.

    John> I have to get JSP debugging setup to do that.  Do you know if eclipse
    John> supports
    John> JSP debugging with Tomcat?

You're not debugging JSP pages, you're debugging pure java code.  You just set
breakpoints in the tag handler code itself, and in your form bean code.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: OptionsCollection and default value

Posted by John Menke <jm...@basebeans.com>.
> At this point, I would be executing this in the debugger, and
> tracing through
> the SelectTag code, and your form bean code.
>

I have to get JSP debugging setup to do that.  Do you know if eclipse
supports
JSP debugging with Tomcat?

-jm


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OptionsCollection and default value

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "John" == John Menke <jm...@basebeans.com> writes:

    >> Are you sure that "taskCodeType" in your form bean is being set to
    >> the appropriate value before being directed to the jsp?

    John> I'm positive this works as I had the formbean working with html:text tags to
    John> test and the taskCodeType variable displays fine.

    John> When I change from html:text to html:select with html:optionsCollection the
    John> option box is populated ok and I can update with values i select in the
    John> option box, but the
    John> current value is never selected initially.

At this point, I would be executing this in the debugger, and tracing through
the SelectTag code, and your form bean code.

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net   ; SCJP



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: OptionsCollection and default value

Posted by John Menke <jm...@basebeans.com>.
>
> Are you sure that "taskCodeType" in your form bean is being set to
> the appropriate value before being directed to the jsp?
>

I'm positive this works as I had the formbean working with html:text tags to
test and the taskCodeType variable displays fine.

When I change from html:text to html:select with html:optionsCollection the
option box is populated ok and I can update with values i select in the
option box, but the
current value is never selected initially.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: OptionsCollection and default value

Posted by Rick Reumann <ma...@reumann.net>.
On Sun, 22 Dec 2002 15:01:42 -0500
"John Menke" <jm...@basebeans.com> wrote:
 
> <html:select property="taskCodeType"><html:optionsCollection
> property="taskCodeTypeOptions"  /></html:select>
> 
> 
> MY JSP WILL RUN AND POPULATE THE SELECT TAG CORRECTLY, BUT IT DOESN'T
> CHOOSE THE CORRECT INITIAL VALUE.
> 
> IE. THE "SELECTED" property is not set correctly.
> 

Are you sure that "taskCodeType" in your form bean is being set to
the appropriate value before being directed to the jsp?  


-- 
Rick

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>