Hi Friends,

I am not able to understand why my parameters are not being accepted by my
action class.please help to resolve this.i included defaultStack after i
dint able to make it by <default-interceptor-ref
name="paramsPrepareParamsStack" />.please find action class,jsp,stryts.xml

ServiceOwnerAndSuscriptionDetails.java
package com.teleparadigm.mms.application.common;

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;
import com.teleparadigm.mms.application.utills.Configuration;

//http://thefiles.macadamian.com/2008/04/struts-2-doubleselect-detailed-example.html

/*
         <s:doubleselect
            name="selectSO"         doubleName="selectSO_Sub"
            list="serviceOwners"       doubleList="subscriptions"
            listKey="serviceOwnerId"          doubleListKey="subscriptionId"
            listValue="serviceOwnerName"     
doubleListValue="subsriptionName"
            value="defaultItem"   doubleValue="doubleDefaultItem" />

 * */
public class ServiceOwnerAndSuscriptionDetails extends ActionSupport
implements ServletRequestAware,ServletResponseAware
{

        Configuration conf = null;

        private HttpServletRequest request;
        private HttpServletResponse response;

        public void setServletRequest(HttpServletRequest request){
                this.request = request;
        }

        public HttpServletRequest getServletRequest(){
                return request;
        }

        public void setServletResponse(HttpServletResponse response){
                this.response = response;
        }

        public HttpServletResponse getServletResponse(){
                return response;
        }
        String ServiceOwnerId;
        String ServiceOwnerName;
        String DefaultItem;
        String DoubleDefaultItem;
        String SubscriptionType;
        List <ServiceOwnerAndSuscriptionDetails> ServiceOwners;
        List <SubscriptionDetails> Subscriptions;
        HttpSession session=null;
        public String execute() throws Exception {
                session=request.getSession(false);

                if(session==null ){

                        addActionError("Invalid Session! Please Relogin!");
                        return ERROR;   
                }
                Owner ownerobj=(Owner)session.getAttribute("ownerobj");
                if(ownerobj==null){

                        addActionError("Invalid User Session!");
                        return ERROR;
                }
                
                Enumeration enumeration=request.getParameterNames(); 
                while(enumeration.hasMoreElements()){
                        String name=(String)enumeration.nextElement();
                        
System.out.println("ServiceOwnerAndSuscriptionDetails---name-->"+name);
                        String value= request.getParameter(name);
                
System.out.println("ServiceOwnerAndSuscriptionDetails---value--->"+value);
                }
                session.setAttribute("ServiceOwners", getServiceOwners());
                session.setAttribute("Subscriptions", getSubscriptions());
                return SUCCESS;
        }
        public String getServiceOwnerId() {
                return ServiceOwnerId;
        }
        public void setServiceOwnerId(String serviceOwnerId) {
                ServiceOwnerId = serviceOwnerId;
        }
        public String getServiceOwnerName() {
                return ServiceOwnerName;
        }
        public void setServiceOwnerName(String serviceOwnerName) {
                ServiceOwnerName = serviceOwnerName;
        }
        public List<ServiceOwnerAndSuscriptionDetails> getServiceOwners() {
                ServiceOwnerAndSuscriptionDetailsDAO sodao=new
ServiceOwnerAndSuscriptionDetailsDAO();
                if(ServiceOwners==null ){
                        ServiceOwners=new 
ArrayList<ServiceOwnerAndSuscriptionDetails>();
                        ServiceOwners=sodao.getServiceOwners();
                        if(ServiceOwners.isEmpty()){
                                this.setServiceOwnerId("");
                                this.setServiceOwnerName("");
                                this.setDefaultItem("");

                        }
                        else
                        {
                                ServiceOwnerAndSuscriptionDetails 
so=ServiceOwners.get(0);
                                this.setServiceOwnerId(so.getServiceOwnerId());
                                
this.setServiceOwnerName(so.getServiceOwnerName());
                                this.setDefaultItem(so.getServiceOwnerName());
                        }
                }
                return ServiceOwners;
        }
        public void setServiceOwners(
                        List<ServiceOwnerAndSuscriptionDetails> serviceOwners) {
                ServiceOwners = serviceOwners;
        }
        public List<SubscriptionDetails> getSubscriptions() {
                ServiceOwnerAndSuscriptionDetailsDAO sodao=new
ServiceOwnerAndSuscriptionDetailsDAO();
                if(Subscriptions==null ){
                        Subscriptions=new ArrayList<SubscriptionDetails>();
                        
System.out.println("getServiceOwnerId-->"+this.getServiceOwnerId());
                
Subscriptions=sodao.getSubscriptions(this.getServiceOwnerId(),this.getSubscriptionType());
                        System.out.println("Subscriptions-->"+Subscriptions);
                        if(Subscriptions.isEmpty()){
                                this.setDoubleDefaultItem("");
                        }else{
                                SubscriptionDetails sd=Subscriptions.get(0);
                                
this.setDoubleDefaultItem(sd.getSubsriptionName());
                        }
                }

                return Subscriptions;
        }
        public void setSubscriptions(List<SubscriptionDetails> subscriptions) {
                Subscriptions = subscriptions;
        }
        public String getDefaultItem() {
                return DefaultItem;
        }
        public void setDefaultItem(String defaultItem) {
                DefaultItem = defaultItem;
        }
        public String getDoubleDefaultItem() {
                return DoubleDefaultItem;
        }
        public void setDoubleDefaultItem(String doubleDefaultItem) {
                DoubleDefaultItem = doubleDefaultItem;
        }

        public String getSubscriptionType() {
                return SubscriptionType;
        }

        public void setSubscriptionType(String subscriptionType) {
                SubscriptionType = subscriptionType;
        }
}

struts.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd";>

<struts>
        <constant name="struts.custom.i18n.resources"
                value="MMSApplicationMessages" />
        <constant name="struts.enable.DynamicMethodInvocation"
                value="false" />
        <!-- Some or all of these can be flipped to true for debugging -->

        <constant name="struts.devMode" value="false" />
        <constant name="struts.configuration.xml.reload" value="true" />

        <!--  
                Constants can be delared in two ways in struts.xml or 
struts.properties
                <constant name="struts.devMode" value="true" />
        -->
        <include file="struts-default.xml" />

        <package name="sajid" extends="struts-default">

                <default-interceptor-ref name="paramsPrepareParamsStack" />

                  <action name="beforeComposeMMS"
                
class="com.teleparadigm.mms.application.common.ServiceOwnerAndSuscriptionDetails">
                        MMS
                        <interceptor-ref name="defaultStack"></interceptor-ref>
                        <result name="error" type="redirect">
                                /pages/ComposeMMS.jsp
                        </result>
                        <result>/pages/ComposeMMS.jsp</result>
                </action>
</package>


</struts>


in JSP

<li><s:url var="url" action="beforeComposeMMS"/><s:a href="%{url}">Compose
MMS</s:a></li>
-- 
View this message in context: 
http://www.nabble.com/Parameters--shows-null-please-help-tp22657568p22657568.html
Sent from the Struts - User mailing list archive at Nabble.com.


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

Reply via email to