rahul1671986 / struts2-jquery

Automatically exported from code.google.com/p/struts2-jquery
0 stars 0 forks source link

Unable to invoke action from <sj:select> #1085

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
(This is for feature requests and bugs in Struts2 jQuery Plugin - for
getting help, please use the User Group.
http://groups.google.com/group/struts2-jquery )

What steps will reproduce the problem?
1.I dont see any action being generated on selecting a value from <sj:select> 
in the jsp page
2.
3.

What is the expected output? What do you see instead?
An action is to be generated and corresponding action class needs to be invoked.

Which struts2 version?
Struts2 2.3.15

Which struts2-jquery plugin version?
struts2-jquery plugin 1.4

Please provide any additional information below.

Here is my jsp page 

<p>Welcome <s:property value = "userName" />.</p>
    <s:select name="entity" list="entities" label="Entity"/>
    <s:select name="subEntity" list="sub_entities" label="Sub Entity"/>&nbsp;&nbsp;
    <!--<s:select name="choice" list="choice_made" /> -->

    <s:url var="remoteurl" action ="FetchData"/>
        <sj:select
                href="%{remoteurl}"
                onChangeTopics="reloadsecondlist"
                name="choice"
                id="choice"
                emptyOption="true"
                list="choice_made"
                />

        <sj:select
            href="%{remoteurl}"
            reloadTopics="reloadsecondlist"
            name="echo" 
            emptyOption="true"
            list="extractedList" />

Here is my Action class

public class FetchData extends ActionSupport{

    TextFileReader reader;

//    @Actions({
//        @Action(
//        value="/FetchData",
//        results={
//        @Result(name="success",type="json")
//        })
//    })

    public FetchData() {
        reader =new TextFileReader();
    }

    private String subEntity;
    private String choice;
    private List<String> extractedList = null;

    ...Getters and Setters......

    public String execute(){

        setExtractedList(getData());       
        return "SUCCESS";
    } 

    private List<String> getData() {

        String[] dataHolder;
        if (subEntity.equals("Drinking water") && choice.equals("yes")) {
            dataHolder = reader.extractData("../config files/type_of_drinking_water.txt");
            for (int i = 0; i < dataHolder.length; i++) {
                extractedList.add(dataHolder[i]);     
            }

        } else if(subEntity.equals("Drinking water") && choice.equals("no")){
            extractedList.add("no");
        }
        else if (subEntity.equals("Approach road") && choice.equals("yes")){
            dataHolder =  reader.extractData("../config files/types_of_approach_road.txt");
            for (int i = 0; i < dataHolder.length; i++) {
                extractedList.add(dataHolder[i]);     
            }      
        }else if (subEntity.equals("Approach road") && choice.equals("no")){
                extractedList.add("no");
        }else if (subEntity.equals("Inner road") && choice.equals("yes")) {
            dataHolder =  reader.extractData("../config files/types_of_inner_road.txt");

            for (int i = 0; i < dataHolder.length; i++) {
                extractedList.add(dataHolder[i]);     
            }  
        }else if (subEntity.equals("Inner road") && choice.equals("no")){
             extractedList.add("no");
        }
        return extractedList;
    }

    public String getJSON(){
        return execute();
    }

This action class is never being invoked....i Have no idea where i am lost. 
Please help me. Also i am unable to add @Actions annotation in the action 
class. It shows an error "annotation type not applicable to this kind of 
declaration".

Original issue reported on code.google.com by chaitu0...@gmail.com on 6 Mar 2014 at 7:11