aspose file tools*
The moose likes Struts and the fly likes passing hidden value to action class in struts-2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "passing hidden value to action class in struts-2" Watch "passing hidden value to action class in struts-2" New topic
Author

passing hidden value to action class in struts-2

Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
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...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Pradeep Adibatla
Ranch Hand

Joined: Oct 27, 2009
Posts: 336
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

Joined: Aug 03, 2008
Posts: 9321
    
  17

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

Joined: Oct 27, 2009
Posts: 336
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...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing hidden value to action class in struts-2