You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "K.M.Prabhu" <pr...@india.adventnet.com> on 2003/08/07 15:26:14 UTC

Remove a key from collection.

Hi All,
I am having a collection of properties with keys of the form, say 
1,2,3,4,..... Of these, a few keys are well known (say 1,2,3) and  the 
others will be
added to the properties object at run time. I want to display them in an 
order in my UI, say 1,2,3,4......  To do this, first I get the values 
for the
known keys (1,2,3). For the remaining things, I put them in a loop and 
print it. But, the problem I face is , the already printed value will 
also print
once again (since I will not know if the key is present in my known list 
or not). My question is how can i remove the key values once i print it.

Can anyone help me?

Thanks,
Prabhu


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


Re: Remove a key from collection.

Posted by "K.M.Prabhu" <pr...@india.adventnet.com>.
I am having a properties in my Action class and i will set it in the 
session. In properties, i know some keys(say a,b,c). In my JSP page 
using the following JSTL, print the values for those keys.
<core:out value="a"/><c:out value="${prop.a}"/>
<core:out value="b"/><c:out value="${prop.b}"/>
After printing the known keys, want to print the remaing pairs. For that 
what i have did is using <core:forEach> loop printed everything. Whats 
the issue in this is, the already printed values also printing once again.
For example,
a : A
b : B
e : E
d : D
c : C
b : B
a : A

So i want to remove the 'a' and 'b' after printing it and before passing 
it to the loop.
In Simple word, properties.remove("a") in Java.

Is it achieved via any JSTL tags.

Rgds,
Prabhu

Erez Efrati wrote:

>I don't really have the entire picture here but I would suggest: 
>
>In you PropertiesBean split between the known, and dynamic containers of
>properties and then in the page pull them using different property on
>the PropertiesBean. This way it would be much more clear which is
>expected and which is dynamically added.
>Simply put to HashMaps on the PropBean and two sets of set/get to get
>and set those properties.
>
>This is only one solution I guess there are more. :)
>
>Hope this helps,
>Erez
>
>-----Original Message-----
>From: K.M.Prabhu [mailto:prabhukm@india.adventnet.com] 
>Sent: Thursday, August 07, 2003 3:26 PM
>To: struts-user@jakarta.apache.org
>Subject: Remove a key from collection.
>
>Hi All,
>I am having a collection of properties with keys of the form, say 
>1,2,3,4,..... Of these, a few keys are well known (say 1,2,3) and  the 
>others will be
>added to the properties object at run time. I want to display them in an
>
>order in my UI, say 1,2,3,4......  To do this, first I get the values 
>for the
>known keys (1,2,3). For the remaining things, I put them in a loop and 
>print it. But, the problem I face is , the already printed value will 
>also print
>once again (since I will not know if the key is present in my known list
>
>or not). My question is how can i remove the key values once i print it.
>
>Can anyone help me?
>
>Thanks,
>Prabhu
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>



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


RE: Remove a key from collection.

Posted by Erez Efrati <er...@netmedia.net.il>.
I don't really have the entire picture here but I would suggest: 

In you PropertiesBean split between the known, and dynamic containers of
properties and then in the page pull them using different property on
the PropertiesBean. This way it would be much more clear which is
expected and which is dynamically added.
Simply put to HashMaps on the PropBean and two sets of set/get to get
and set those properties.

This is only one solution I guess there are more. :)

Hope this helps,
Erez

-----Original Message-----
From: K.M.Prabhu [mailto:prabhukm@india.adventnet.com] 
Sent: Thursday, August 07, 2003 3:26 PM
To: struts-user@jakarta.apache.org
Subject: Remove a key from collection.

Hi All,
I am having a collection of properties with keys of the form, say 
1,2,3,4,..... Of these, a few keys are well known (say 1,2,3) and  the 
others will be
added to the properties object at run time. I want to display them in an

order in my UI, say 1,2,3,4......  To do this, first I get the values 
for the
known keys (1,2,3). For the remaining things, I put them in a loop and 
print it. But, the problem I face is , the already printed value will 
also print
once again (since I will not know if the key is present in my known list

or not). My question is how can i remove the key values once i print it.

Can anyone help me?

Thanks,
Prabhu


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




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