Package com.simoncat.actions

Source Code of com.simoncat.actions.ListingServersScreenAction

package com.simoncat.actions;

import org.apache.struts.action.*;
import javax.servlet.http.*;
import com.simoncat.vo.Server;
import com.simoncat.beans.ListingServersScreenOutput;
import com.simoncat.beans.FinalScreenOutput;
import com.simoncat.Constants;
import java.util.Collection;
import java.util.ArrayList;

import com.simoncat.beans.XMLServers;

public final class ListingServersScreenAction extends Action {

   public ActionForward execute(ActionMapping mapping,
                                ActionForm form,
                                HttpServletRequest request,
                                HttpServletResponse response) throws Exception {

      HttpSession session = request.getSession();

      // Owner's contact (look for it into HttpSession)
      Server co = (Server)session.getAttribute("server_data");

      // Collection of friend's contacts (look for it into HttpSession)
      Collection c = (Collection)session.getAttribute("friends_data2");


      //READ XML

      Server ss[];
        
   
      XMLServers xmlserver = new XMLServers();
      ss=xmlserver.readXmls("", this.getServlet().getServletContext());
      if(ss==null){
    FinalScreenOutput fso = new FinalScreenOutput();
    fso.setPageTitle    ("List Servers [Finished]");

    fso.setMessage       ("No existen servidores para listar!");
    if (Constants.xmlOutputOnly) {
        request.setAttribute ("content", Constants.xmlContentType);
    } else {
        request.setAttribute ("content", Constants.htmlContentType);
        request.setAttribute ("style", "confirm.xsl");
    }
    request.setAttribute ("form", fso);

    return (mapping.findForward(Constants.XMLHandler));
      }


      // Now, let's prepare output
      ListingServersScreenOutput lso = new ListingServersScreenOutput();
      lso.setPageTitle    ("List Servers");
      //for(int i=0;i<ss.length;i++) 
  //  lso.setServer(co);//ss[i]);

      lso.setServer        (co);
      lso.setFriends      (c);



            //session.setAttribute ("friends_data2", c);     

            Collection coo = new ArrayList();
      for(int j=0;j<ss.length;j++
              coo.add (ss[j]);
     

    //  for(int i=0;i<ss.length;i++) 
    lso.setServers(coo);//ss[i]);

      if (Constants.xmlOutputOnly) {
          request.setAttribute ("content", Constants.xmlContentType);
      } else {
          request.setAttribute ("content", Constants.htmlContentType);
          request.setAttribute ("style", "listingServers.xsl");
      }
      request.setAttribute ("form", lso);

      return (mapping.findForward(Constants.XMLHandler));
   }

}
TOP

Related Classes of com.simoncat.actions.ListingServersScreenAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.