You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Yaragalla Muralidhar <ya...@gmail.com> on 2015/08/27 11:17:06 UTC
How to access a map in jsp
Hi,
the following is the code in action class
//_________________________________________________
private List<AntibioticDto> antibiotics;
private List<OrganismType> organismTypes;
private Map<String, List<String>> oaMap;
@Override
public String execute() throws Exception {
try{
antibiotics=dtService.getAllAntibioticsList();
organismTypes=dtService.getAllOrganisumTypes();
oaMap=dtService.getAllSelectedOrganismTypeAntibiotics();
}catch(Exception e){
log.error(e.getMessage(), e);
return "error";
}
return SUCCESS;
}
//_________________________________________________________
The following is the code in jsp
<s:iterator value="antibiotics" status="status">
<tr><td><s:property value="antibioticName"/></td>
<s:iterator value="organismTypes">
<td style="width:100px"><input type="checkbox" <s:if test="%{oaMap.[((new
Integer(antibioticId).toString()))].contains((new
Integer(organismTypeId).toString()))}">checked</s:if> value='<s:property
value="antibioticId"/>' style="line-height: 35px;" /></td>
</s:iterator>
</tr>
</s:iterator>
//______________________________________________________________
i am trying to get the arrylist from the map and trying to check whether it
contains a particular string but this is not working? is this the right way
to do this? If not how to do this?
*Thanks and Regards,*
Muralidhar Yaragalla.
*http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>*
Re: How to access a map in jsp
Posted by Yaragalla Muralidhar <ya...@gmail.com>.
i have added methods to get the primitive integers as strings in dto. that
solved my problem. thanks Christoph.
*Thanks and Regards,*
Muralidhar Yaragalla.
*http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>*
On Thu, Aug 27, 2015 at 2:56 PM, Christoph Nenning <
Christoph.Nenning@lex-com.net> wrote:
> What are the types of antibioticId and organismTypeId ?
> Are they primitive integers/longs?
> I would add methods to DTOs to get them as Strings.
>
>
> I suggest to store the list in a pageScope variable, to make the
> expression better readable.
> There should be no dot before the bracket. You wrote "oaMap.[", it should
> be "oaMap["
>
>
>
> <s:set var="_oaList" value="oaMap[antibioticId]" />
> <s:if test="_oaList.contains(organismTypeId)">....
>
>
>
>
>
> Regards,
> Christoph
>
>
>
>
>
>
> Yaragalla Muralidhar <ya...@gmail.com> schrieb am 27.08.2015
> 11:17:06:
>
> > From: Yaragalla Muralidhar <ya...@gmail.com>
> > To: Struts Users Mailing List <us...@struts.apache.org>,
> > Date: 27.08.2015 11:17
> > Subject: How to access a map in jsp
> >
> > Hi,
> > the following is the code in action class
> >
> > //_________________________________________________
> > private List<AntibioticDto> antibiotics;
> > private List<OrganismType> organismTypes;
> > private Map<String, List<String>> oaMap;
> > @Override
> > public String execute() throws Exception {
> > try{
> > antibiotics=dtService.getAllAntibioticsList();
> > organismTypes=dtService.getAllOrganisumTypes();
> > oaMap=dtService.getAllSelectedOrganismTypeAntibiotics();
> > }catch(Exception e){
> > log.error(e.getMessage(), e);
> > return "error";
> > }
> > return SUCCESS;
> > }
> > //_________________________________________________________
> >
> > The following is the code in jsp
> >
> > <s:iterator value="antibiotics" status="status">
> > <tr><td><s:property value="antibioticName"/></td>
> > <s:iterator value="organismTypes">
> > <td style="width:100px"><input type="checkbox" <s:if
> test="%{oaMap.[((new
> > Integer(antibioticId).toString()))].contains((new
> > Integer(organismTypeId).toString()))}">checked</s:if> value='<s:property
> > value="antibioticId"/>' style="line-height: 35px;" /></td>
> > </s:iterator>
> > </tr>
> > </s:iterator>
> >
> > //______________________________________________________________
> >
> > i am trying to get the arrylist from the map and trying to check whether
> it
> > contains a particular string but this is not working? is this the right
> way
> > to do this? If not how to do this?
> >
> > *Thanks and Regards,*
> > Muralidhar Yaragalla.
> >
> > *http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>*
>
> This Email was scanned by Sophos Anti Virus
>
Re: How to access a map in jsp
Posted by Christoph Nenning <Ch...@lex-com.net>.
What are the types of antibioticId and organismTypeId ?
Are they primitive integers/longs?
I would add methods to DTOs to get them as Strings.
I suggest to store the list in a pageScope variable, to make the
expression better readable.
There should be no dot before the bracket. You wrote "oaMap.[", it should
be "oaMap["
<s:set var="_oaList" value="oaMap[antibioticId]" />
<s:if test="_oaList.contains(organismTypeId)">....
Regards,
Christoph
Yaragalla Muralidhar <ya...@gmail.com> schrieb am 27.08.2015
11:17:06:
> From: Yaragalla Muralidhar <ya...@gmail.com>
> To: Struts Users Mailing List <us...@struts.apache.org>,
> Date: 27.08.2015 11:17
> Subject: How to access a map in jsp
>
> Hi,
> the following is the code in action class
>
> //_________________________________________________
> private List<AntibioticDto> antibiotics;
> private List<OrganismType> organismTypes;
> private Map<String, List<String>> oaMap;
> @Override
> public String execute() throws Exception {
> try{
> antibiotics=dtService.getAllAntibioticsList();
> organismTypes=dtService.getAllOrganisumTypes();
> oaMap=dtService.getAllSelectedOrganismTypeAntibiotics();
> }catch(Exception e){
> log.error(e.getMessage(), e);
> return "error";
> }
> return SUCCESS;
> }
> //_________________________________________________________
>
> The following is the code in jsp
>
> <s:iterator value="antibiotics" status="status">
> <tr><td><s:property value="antibioticName"/></td>
> <s:iterator value="organismTypes">
> <td style="width:100px"><input type="checkbox" <s:if
test="%{oaMap.[((new
> Integer(antibioticId).toString()))].contains((new
> Integer(organismTypeId).toString()))}">checked</s:if> value='<s:property
> value="antibioticId"/>' style="line-height: 35px;" /></td>
> </s:iterator>
> </tr>
> </s:iterator>
>
> //______________________________________________________________
>
> i am trying to get the arrylist from the map and trying to check whether
it
> contains a particular string but this is not working? is this the right
way
> to do this? If not how to do this?
>
> *Thanks and Regards,*
> Muralidhar Yaragalla.
>
> *http://yaragalla.blogspot.in/ <http://yaragalla.blogspot.in/>*
This Email was scanned by Sophos Anti Virus