You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2005/12/01 17:28:37 UTC
Re: Repost:- Accessing an array from within a JSP
Mon Cab wrote:
> Sorry. The formatting was messed up on my first post. Hopefully this
> is better
>
> I am trying to define a string array as a property of DynaValidatorForm
> in my struts config file and then access that array from within a JSP
> but am getting an incompatible types error when trying to do this.
> My frorm bean definition is as follows:
>
> <form-bean
> name="myDynaActionForm"
> type="org.apache.struts.validator.DynaValidatorForm">
> <form-property
> name="string_array"
> type="java.lang.String[]"/>
> </form-bean>
>
> In my JSP (MyJSP.jsp) I wrote:
>
> <bean:define
> id="string_array"
> name="myDynaActionForm"
> property="string_array"/>
> <%@ include file="Nested.jsp" %>
>
> And then in my Nested.jsp I tried to access the array as follows:
>
> Object [] stringArray = string_array;
>
> When I try load the page I get the following error (written to
> stdout.log):
>
> An error occurred at line: 6 in the jsp file: /Nested.jsp
> Generated servlet error:
>
> C:\Tomcat Home\MyJSP_jsp.java:211: incompatible types
> found : java.lang.Object
> required: java.lang.Object[]
> Object [] stringArray = string_array;
>
> Am I doing this wrong? How should I be doing this?
Did you try specifying the 'type' attribute in your bean:define tag? Not
sure if that's the problem, but it might help. Or, perhaps, an explicit
cast on the assignment in your scriptlet code.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Repost:- Accessing an array from within a JSP
Posted by Mon Cab <fu...@yahoo.com>.
Lauri
I did an explicit cast and it worked. Thanks so much.
--- Laurie Harper <la...@holoweb.net> wrote:
> Mon Cab wrote:
> > Sorry. The formatting was messed up on my first post. Hopefully
> this
> > is better
> >
> > I am trying to define a string array as a property of
> DynaValidatorForm
> > in my struts config file and then access that array from within a
> JSP
> > but am getting an incompatible types error when trying to do this.
>
> > My frorm bean definition is as follows:
> >
> > <form-bean
> > name="myDynaActionForm"
> > type="org.apache.struts.validator.DynaValidatorForm">
> > <form-property
> > name="string_array"
> > type="java.lang.String[]"/>
> > </form-bean>
> >
> > In my JSP (MyJSP.jsp) I wrote:
> >
> > <bean:define
> > id="string_array"
> > name="myDynaActionForm"
> > property="string_array"/>
> > <%@ include file="Nested.jsp" %>
> >
> > And then in my Nested.jsp I tried to access the array as follows:
> >
> > Object [] stringArray = string_array;
> >
> > When I try load the page I get the following error (written to
> > stdout.log):
> >
> > An error occurred at line: 6 in the jsp file: /Nested.jsp
> > Generated servlet error:
> >
> > C:\Tomcat Home\MyJSP_jsp.java:211: incompatible types
> > found : java.lang.Object
> > required: java.lang.Object[]
> > Object [] stringArray = string_array;
> >
> > Am I doing this wrong? How should I be doing this?
>
> Did you try specifying the 'type' attribute in your bean:define tag?
> Not
> sure if that's the problem, but it might help. Or, perhaps, an
> explicit
> cast on the assignment in your scriptlet code.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
__________________________________________
Yahoo! DSL Something to write home about.
Just $16.99/mo. or less.
dsl.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org