You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marc Tinnemeyer <ma...@gmx.net> on 2004/04/22 16:39:08 UTC

and co

hi everybody,

I got a collection in session scope which contains a lot of properties
that I want to use to fill comboboxes etc.

the objects stored in this collection look like:

id(int), property(string), value(string)

The propertyfield indicates where the object belongs to (eg. country or
os...).
So in my JSPs I want to iterate through this collection an pick the
objects belonging to the current combobox.
That's the theory, practically there is s.th. that keeps me from doing
this.

Here is what I did so far.

my collection is called "PROPERTIES".


<html:select property="bundesland" size="1">
 <logic:iterate name="PROPERTIES" id="element" >
  <logic:equal name="element" property="property" value="bundesland">
   <html:option value="<bean:write name="element" property="id" />" >
    <bean:write name="element" property="value" />
   </html:option>
  </logic:equal>
 </logic:iterate>
</html:select>


When I call that jsp, I receive the follwing error message "equal
symbol expected" (which points at):  
<html:option value="<bean:write name="element" property="id" />" >
                                            ^^

So I replaced the doublequotes by singlequotes, which let the error
disappear, while putting the whole string "<bean:write..." into my
valuefield :-(


Does anybody ever encountered a similar problem, and solved it or does
somebody have an idea how to solve this, maybe even in a more elegant way
?

Thanks in advance,

Kind Regards,
Marc Tinnemeyer

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


Re: and co

Posted by Marc Tinnemeyer <ma...@gmx.net>.
My Intention was to create a "mulitpurpose"-Collection, that contains
some stuff I need regulary. But maybe it's a better approach to split
them into several collections and then use the <html:options...

I dont' want to use standard html <option>-Tag because sometimes I need
an entry in the comboxbox preselected and the struts
<html:option(s)>-Tags handle this quite well.

So I guess I'll split my "super-collection". 

Thanks again for your replies !

Marc


On Thu, 22 Apr 2004 13:28:33 -0300
"Henrique VIECILI" <vi...@softplan.com.br> wrote:

> Marc,
> 
> i think the best way, according to the MVC pattern (JSP is the View),
> you should split the collection in 2 collections leaving the Control
> to your Action. But if you don_t wanna do this you can try to use just
> <option value='<bean:write ..../>' > instead of <html:option>
> 
> Henrique

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


Re: and co

Posted by Henrique VIECILI <vi...@softplan.com.br>.
Marc,

i think the best way, according to the MVC pattern (JSP is the View), you should
split the collection in 2 collections leaving the Control to your Action. But if
you don´t wanna do this you can try to use just <option value='<bean:write ....
/>' > instead of <html:option>

Henrique

----- Original Message ----- 
From: "Marc Tinnemeyer" <ma...@gmx.net>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Thursday, April 22, 2004 12:49 PM
Subject: Re: <html:option /> and co


> Thanks for your response Henrique,
>
> I already tried your solution, but there is a problem with it.
> I don't want to get all objects from that collection only those that
> have an attribute that matches a certain value.
>
> for example:
> in my collection I have three objects with the following attributes:
>
> object 1:
> id=1
> property=country
> value=Brazil
>
> object 2:
> id=2
> property=sex
> value=female
>
> object 3:
> id=3
> property=country
> value=France
>
> now i have a comboxbox that shall display all my countries but not the
> sexes. that's why I tried to do it using <logic:equal...>. so I need to
> find a way to get only those objects from the collection that all have
> the same "property"-field.
>
> Marc
>
>
>
> On Thu, 22 Apr 2004 11:52:39 -0300
> "Henrique VIECILI" <vi...@softplan.com.br> wrote:
>
> > Hi Marc,
> >
> > if you have a collection, it would be nice to use the <html:options>
> > tag, which iterates over a collection rendering <option> tags (you
> > shall place inside<html:select> or <select> to make sense)
> >
> > in your case:
> >
> > <html:options collection="PROPERTIES" property="id"
> > labelProperty="value" />
> >
> > i guess it will work!
> >
> > []_s
> > Henrique Viecili
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: and co

Posted by Marc Tinnemeyer <ma...@gmx.net>.
Thanks for your response Henrique,

I already tried your solution, but there is a problem with it. 
I don't want to get all objects from that collection only those that
have an attribute that matches a certain value.

for example:
in my collection I have three objects with the following attributes:

object 1:
id=1
property=country
value=Brazil

object 2:
id=2
property=sex
value=female

object 3:
id=3
property=country
value=France

now i have a comboxbox that shall display all my countries but not the
sexes. that's why I tried to do it using <logic:equal...>. so I need to
find a way to get only those objects from the collection that all have
the same "property"-field.

Marc



On Thu, 22 Apr 2004 11:52:39 -0300
"Henrique VIECILI" <vi...@softplan.com.br> wrote:

> Hi Marc,
> 
> if you have a collection, it would be nice to use the <html:options>
> tag, which iterates over a collection rendering <option> tags (you
> shall place inside<html:select> or <select> to make sense)
> 
> in your case:
> 
> <html:options collection="PROPERTIES" property="id"
> labelProperty="value" />
> 
> i guess it will work!
> 
> []_s
> Henrique Viecili

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


Re: and co

Posted by Henrique VIECILI <vi...@softplan.com.br>.
Hi Marc,

if you have a collection, it would be nice to use the <html:options> tag, which
iterates over a collection rendering <option> tags (you shall place inside
<html:select> or <select> to make sense)

in your case:

<html:options collection="PROPERTIES" property="id" labelProperty="value" />

i guess it will work!

[]´s
Henrique Viecili

----- Original Message ----- 
From: "Marc Tinnemeyer" <ma...@gmx.net>
To: <st...@jakarta.apache.org>
Sent: Thursday, April 22, 2004 11:39 AM
Subject: <html:option /> and co


> hi everybody,
>
> I got a collection in session scope which contains a lot of properties
> that I want to use to fill comboboxes etc.
>
> the objects stored in this collection look like:
>
> id(int), property(string), value(string)
>
> The propertyfield indicates where the object belongs to (eg. country or
> os...).
> So in my JSPs I want to iterate through this collection an pick the
> objects belonging to the current combobox.
> That's the theory, practically there is s.th. that keeps me from doing
> this.
>
> Here is what I did so far.
>
> my collection is called "PROPERTIES".
>
>
> <html:select property="bundesland" size="1">
>  <logic:iterate name="PROPERTIES" id="element" >
>   <logic:equal name="element" property="property" value="bundesland">
>    <html:option value="<bean:write name="element" property="id" />" >
>     <bean:write name="element" property="value" />
>    </html:option>
>   </logic:equal>
>  </logic:iterate>
> </html:select>
>
>
> When I call that jsp, I receive the follwing error message "equal
> symbol expected" (which points at):
> <html:option value="<bean:write name="element" property="id" />" >
>                                             ^^
>
> So I replaced the doublequotes by singlequotes, which let the error
> disappear, while putting the whole string "<bean:write..." into my
> valuefield :-(
>
>
> Does anybody ever encountered a similar problem, and solved it or does
> somebody have an idea how to solve this, maybe even in a more elegant way
> ?
>
> Thanks in advance,
>
> Kind Regards,
> Marc Tinnemeyer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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