Ajuda Struts 2 double select

1 resposta
acmprotector

Alow pessoal blz…

Peguei um exemplo de double select usando struts do site :http://code.google.com/p/struts2-jquery/wiki/SelectTag e estou a tentar implementar mas sem usar anotacoes.

segue o codigo abaixo:

struts.xml

<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <!-- Configuration for the default package. -->    
    <package name="default" extends="struts-default,json-default" namespace="/">
        <action name="jsonsample" class="struts2.actions.JsonSample">
            <result type="json"></result>
        </action>
    </package>
</struts>

index.jsp

<%@taglib prefix="s" uri="/struts-tags"%>
<%@taglib uri="/struts2-jquery-tags" prefix="sj"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
       <s:form id="formSelectReload" theme="simple" cssClass="yform">
    <fieldset>
        <legend>AJAX Form</legend>
        <div class="type-text">
            <label for="language">Language: </label>
                        <s:url id="remoteurl" action="jsonsample"/>
                        <sj:select
                                <sj:select
                                      href="%{remoteurl}"
                                      id="echo2"
                                      name="echo"
                                      list="languageMap"
                                      emptyOption="true"
                                      headerKey="-1"
                                     headerValue="Please Select a Language"/>
        </div>
        <div class="type-text">
            <label for="echo">Framework: </label>
                        <sj:select
                                href="%{remoteurl}"
                                id="selectWithReloadTopic"
                                formIds="formSelectReload"
                                reloadTopics="reloadsecondlist"
                                name="echo"
                                list="reloadList"
                                emptyOption="false"
                                headerKey="-1"
                                headerValue="Please Select a Framework"/>
        </div>
        <div class="type-button">
                        <sj:submit
                                targets="result"
                                value="AJAX Submit"
                                indicator="indicator"/>
                        <img id="indicator" src="images/loading.gif" alt="Loading..." style="display:none"/>
        </div>
    </fieldset>
</s:form>
    </body>
</html>

A classe action JsonSample.java

import com.opensymphony.xwork2.ActionSupport;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * @author Microsse
 */

public class JsonSample extends ActionSupport{
    private Map<String, String> languageMap;
    private List<String>        reloadList;
    private String              language;


   
    @Override
    public String execute() throws Exception {

      languageMap = new HashMap<String, String>();

      languageMap.put("J", "Java");
      languageMap.put("P", "PHP");
      languageMap.put("C", "C#");



    reloadList = new ArrayList<String>();
    if (language != null && language.equalsIgnoreCase("J"))
    {
      reloadList.add("Struts2");
      reloadList.add("MyFaces");
      reloadList.add("Tapestry");
    }
    else if (language != null && language.equalsIgnoreCase("P"))
    {
      reloadList.add("CakePHP");
      reloadList.add("Symfony");
      reloadList.add("Zend");
    }
    else if (language != null && language.equalsIgnoreCase("C"))
    {
      reloadList.add("NStruts");
      reloadList.add("ProMesh.NET");
      reloadList.add("Websharp");
    }

      return "success";
    }
    
//getters e setters
}

O problema e que na hora que vou executar os dados nao estao a ser populado no select.

Grato pela atencao.

1 Resposta

acmprotector

alguem??

Criado 3 de novembro de 2011
Ultima resposta 4 de nov. de 2011
Respostas 1
Participantes 1