You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by mo...@physics.gmu.edu on 2003/12/02 22:34:42 UTC

logic:iterate and Map

Hi All i am doing the following

	  <logic:iterate id="aciterator" name="rsiappForm"
property="appCoursesMap"  >
      <tr>

        <td width="15%"><div align="center">
          <html:radio  property="appCourse(<%=aciterator.key%>).level"
value="regular" />
        </div></td>
        <td width="15%"><div align="center">
          <html:radio property="appCourse(<%=aciterator.key%>).level" 
value="honors" />
</logic:iterate>

where appCoursesMap is a Map initialized as a HashMap.
I am getting an error as follows
Since fork is true, ignoring compiler setting.
    [javac] Compiling 1 source file
    [javac] Since fork is true, ignoring compiler setting.
    [javac]
/usr/jakarta-tomcat-4.1.24/work/Standalone/localhost/apps_rsi/forms/rsi_app_step3_form_jsp.java:271:
cannot resolve symbol
    [javac] symbol  : variable key
    [javac] location: class java.lang.Object
    [javac]               out.print(aciterator.key);
    [javac]                                   ^
    [javac] 1 error

at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
	at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
	at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)



I am thinkng the <logic:iterate> tag should take the Map as Map.Entry and
hence i have used the property="appCourse(<%=aciterator.key%>).level".

I have getter and setter methods for appCourse too that take parameter as
key and Key and Value respectively that set this Map.

Please let me know

--Mohan



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: logic:iterate and Map

Posted by mo...@physics.gmu.edu.
Hi Joe underneath should i have it as

> In the scriptlet expression, there is no property "key" on the object
> aciterator; use aciterator.getKey() instead.
>
> However, you can't mix string literals and runtime expressions like
> that in a JSP tag attribute.  If you use a runtime attribute, it must
> be the exclusive content of the attribute, so you need to do something
> like a <bean:define> earlier where you define a bean whose content is
> the "assembled" value, and then use the newly defined bean in a
> scriptlet in the attribute.  (i.e. <bean:define id="foo">

here should be aciterator.key or aciterator.getKey()?

> appCourse(<%=aciterator.key%>).level</bean:define> and then later <%=
> foo %>)
>
> Joe
>
> On Dec 2, 2003, at 3:34 PM, mohan@physics.gmu.edu wrote:
>
>> Hi All i am doing the following
>>
>> 	  <logic:iterate id="aciterator" name="rsiappForm"
>> property="appCoursesMap"  >
>>       <tr>
>>
>>         <td width="15%"><div align="center">
>>           <html:radio  property="appCourse(<%=aciterator.key%>).level"
>> value="regular" />
>>         </div></td>
>>         <td width="15%"><div align="center">
>>           <html:radio property="appCourse(<%=aciterator.key%>).level"
>> value="honors" />
>> </logic:iterate>
>>
>> where appCoursesMap is a Map initialized as a HashMap.
>> I am getting an error as follows
>> Since fork is true, ignoring compiler setting.
>>     [javac] Compiling 1 source file
>>     [javac] Since fork is true, ignoring compiler setting.
>>     [javac]
>> /usr/jakarta-tomcat-4.1.24/work/Standalone/localhost/apps_rsi/forms/
>> rsi_app_step3_form_jsp.java:271:
>> cannot resolve symbol
>>     [javac] symbol  : variable key
>>     [javac] location: class java.lang.Object
>>     [javac]               out.print(aciterator.key);
>>     [javac]                                   ^
>>     [javac] 1 error
>>
>> at
>> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorH
>>  andler.java:130)
>> 	at
>> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.j
>>  ava:293)
>> 	at
>> org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
>> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
>>
>>
>>
>> I am thinkng the <logic:iterate> tag should take the Map as Map.Entry
>>  and
>> hence i have used the property="appCourse(<%=aciterator.key%>).level".
>>
>> I have getter and setter methods for appCourse too that take parameter
>>   as
>> key and Key and Value respectively that set this Map.
>>
>> Please let me know
>>
>> --Mohan
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org For
>> additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
>   "We want beef in dessert if we can get it there."
>    -- Betty Hogan, Director of New Product Development, National
> Cattlemen's Beef Association




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: logic:iterate and Map

Posted by Joe Germuska <jo...@germuska.com>.
In the scriptlet expression, there is no property "key" on the object  
aciterator; use aciterator.getKey() instead.

However, you can't mix string literals and runtime expressions like  
that in a JSP tag attribute.  If you use a runtime attribute, it must  
be the exclusive content of the attribute, so you need to do something  
like a <bean:define> earlier where you define a bean whose content is  
the "assembled" value, and then use the newly defined bean in a  
scriptlet in the attribute.  (i.e. <bean:define id="foo">  
appCourse(<%=aciterator.key%>).level</bean:define> and then later <%=  
foo %>)

Joe

On Dec 2, 2003, at 3:34 PM, mohan@physics.gmu.edu wrote:

> Hi All i am doing the following
>
> 	  <logic:iterate id="aciterator" name="rsiappForm"
> property="appCoursesMap"  >
>       <tr>
>
>         <td width="15%"><div align="center">
>           <html:radio  property="appCourse(<%=aciterator.key%>).level"
> value="regular" />
>         </div></td>
>         <td width="15%"><div align="center">
>           <html:radio property="appCourse(<%=aciterator.key%>).level"
> value="honors" />
> </logic:iterate>
>
> where appCoursesMap is a Map initialized as a HashMap.
> I am getting an error as follows
> Since fork is true, ignoring compiler setting.
>     [javac] Compiling 1 source file
>     [javac] Since fork is true, ignoring compiler setting.
>     [javac]
> /usr/jakarta-tomcat-4.1.24/work/Standalone/localhost/apps_rsi/forms/ 
> rsi_app_step3_form_jsp.java:271:
> cannot resolve symbol
>     [javac] symbol  : variable key
>     [javac] location: class java.lang.Object
>     [javac]               out.print(aciterator.key);
>     [javac]                                   ^
>     [javac] 1 error
>
> at
> org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorH 
> andler.java:130)
> 	at
> org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.j 
> ava:293)
> 	at  
> org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:353)
> 	at org.apache.jasper.compiler.Compiler.compile(Compiler.java:370)
>
>
>
> I am thinkng the <logic:iterate> tag should take the Map as Map.Entry  
> and
> hence i have used the property="appCourse(<%=aciterator.key%>).level".
>
> I have getter and setter methods for appCourse too that take parameter  
> as
> key and Key and Value respectively that set this Map.
>
> Please let me know
>
> --Mohan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
--
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
  "We want beef in dessert if we can get it there."
   -- Betty Hogan, Director of New Product Development, National  
Cattlemen's Beef Association