• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

passing hidden value to action class in struts-2

 
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an iterator like this and on selecting a value i need to get values for another selectag below this tag...

The values in 2 select tags are objects in my application

i.e the second select tag values should be obtained based on the value selected in the first select!



But i am unable to see the value in my action class...
 
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I couldn't understand exactly what you want, but if you want something like first the user should select country and then based upon that you want to show the user a select box of states, then you can use the doubleselect tag.

But i am unable to see the value in my action class...


Basically this statement is confusing me. Are you not able to see the values on the JSP or the values are not getting submitted. I'm not sure if your code is actually working as you have form tag inside select tag...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the code above I just want to send the value selected(as it is an object) and fetch values ... The problem is I don't do a submit while selecting a value...so I can't communicate with action class to get the values for the 2nd select !

I could'nt covert the above code into double select !!!




 
Ankit Garg
Sheriff
Posts: 9707
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When one of the options is selected, you can make an AJAX request to get the values for the 2nd select box. This is one of the ways of implementing what you want...
 
Pradeep Adibatla
Ranch Hand
Posts: 336
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ...

As suggested I wrote an Ajax call, passed the values selected to action class and prepared the values for the 2nd select in a AL...

but alas it's not populating...check it out...

[code]

public class ConditionActionPopUpAction extends ActionSupport
{

private String selectedConcept;
ArrayList conAtrAL;
private LinkedHashMap<String, Attribute> atrHMap1;

public ArrayList getConAtrAL()
{
System.out.println("in getConAtrAL !!! ");
return conAtrAL;
}

public LinkedHashMap<String, Attribute> getAtrHMap1()
{
System.out.println("in getATrHMap1() ");
return atrHMap1;
}

public String getSelectedConcept()
{
System.out.println("in getSelectedConcept !!! ");
System.out.println("The selectedConcept is :---> "+selectedConcept);
return selectedConcept;
}

public void setSelectedConcept(String selectedConcept)
{
this.selectedConcept = selectedConcept;
System.out.println("The selectedConcept is :---> "+selectedConcept);
}

.................

@Override

public String execute() throws Exception
{

System.out.println("in execute() !!! ");
System.out.println("addRule is :-->"+addRule);
System.out.println("The selectedConcept is :--> "+selectedConcept);

conAtrAL=new ArrayList();
atrHMap1=new LinkedHashMap<String, Attribute>();

if(selectedConcept!=null)
{
System.out.println("selC is not null !!! ");

Vocabulary obj_Vocabulary=StorageBean.getVocabulary();
Concept c=obj_Vocabulary.getConceptList().get(selectedConcept);

if(c!=null)
{

System.out.println("Concept c is :--> "+c);

atrHMap1=c.getOverALL_AttributeList();

System.out.println("The size is :--> "+conAtrAL.size());

for (Iterator<String> it = atrHMap1.keySet().iterator(); it.hasNext();)
{
String object = it.next();
System.out.println("Attributes are ---- >"+object);
conAtrAL.add(object.trim());
}
for (Iterator<String> it = conAtrAL.iterator(); it.hasNext();)
{
String st = it.next();
System.out.println("The conAtrAL vals are :--> "+st);
}

}

}

........
........
.......


}




[/code]

The output :-->
---------------------

The selectedConcept is :---> c5
in execute() !!!
addRule is :-->null
The selectedConcept is :--> c5
selC is not null !!!
Concept c is :--> com.infosys.struts.ibrs.model.Concept@11d0ad2
The size is :--> 0
Attributes are ---- >a12
The conAtrAL vals are :--> a12
The target is :-->failure
in getConAtrAL !!!
in getConAtrAL !!!



wonder why the i cant see the values...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic