[jboss-user] [JBoss Portal] - HOW t o get parameter (big5 code in taiwan)

kevnlin do-not-reply at jboss.com
Fri Mar 23 12:29:29 EDT 2007


my portlet class 

/*
 * oper.java
 *
 * Created on 2007?3?15?, ?? 11:42
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.fedora;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portal.api.node.event.PortalNodeEvent;
import org.jboss.portal.api.node.event.PortalNodeEventListener;
import org.jboss.portal.api.node.event.PortalNodeEventContext;
import org.jboss.portal.api.node.event.WindowActionEvent;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.WindowState;
import org.jboss.portlet.JBossPortlet;
import org.jboss.portlet.JBossRenderRequest;
import org.jboss.portlet.JBossRenderResponse;
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
import javax.portlet.*;

import javax.portlet.PortletException;
import java.io.IOException;
import javax.portlet.PortletRequestDispatcher;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.gotdns.fedora.client.*;
import org.jboss.portal.common.util.CollectionBuilder;
import org.jboss.portal.identity.UserModule;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.Role;
import  org.gotdns.fedora.client.*;
import org.jboss.portal.identity.IdentityException;
/**
 *
 * @author kevnlin
 */
public class oper extends JBossPortlet {
     private static final String JSP_PATH = "/WEB-INF/jsp";
       private  org.gotdns.fedora.client.operationclient   home;
    /** Creates a new instance of oper */
   private   String oid="";
     private           String opname="";
      private           String opdesc="";
      private         String oplink="";
      private          String disable="";
      private String opmode="";
   
   public void processAction(JBossActionRequest req, JBossActionResponse resp) throws  PortletException, PortletSecurityException, IOException
   {   
       opmode=  req.getParameter("opmode");
  //     if(opmode == null ){opmode="list";}
      //   resp.setProperty("opmode",opmode);    
    

         resp.setRenderParameter("opmode",opmode);
             opname=req.getParameter("opname");    if(opname == null){opname="";}
             opdesc=req.getParameter("opdesc");  if(opdesc == null){opdesc="";}
             disable=req.getParameter("disable");  if(disable == null){disable="";}
             oplink=req.getParameter("oplink");  if(oplink == null){oplink="";}
             oid=req.getParameter("oid");  if(oid == null){oid="";}
              resp.setRenderParameter("oid",oid);
             System.out.println(opname);
         //    String tt=new String(opname.getBytes(),"utf8");
             String tt="";
           //  tt=new String(tt.getBytes(),"utf-8");
        //  System.out.println(tt);
          tt=new String(opname.getBytes("MS950"),"utf-8");
            System.out.println(tt);
            tt=new String(opname.getBytes("utf-8"),"MS950");
             System.out.println(tt);
         //   System.out.println(new String(opname.getBytes("ms950"),"utf-8")); 
           // System.out.println(new String(opname.getBytes("utf-8"),"mf950")); 
   }
   
     protected void doView(JBossRenderRequest req, JBossRenderResponse resp) throws IOException, PortletException
   {  System.out.println(opname+"VIEW");
        String opmode="";
       
      opmode=  req.getParameter("opmode");
     if(opmode == null){opmode="";}
      resp.setProperty("opmode",opmode);
             resp.setContentType("text/html;charset=UTF-8");
       
      
       javax.portlet.PortletRequestDispatcher pRD =null;   
     
       
    
    if(opmode.equals("list")){
            pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opview.jsp");   
    }else if(opmode.equals("view")){
          pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opdetail.jsp");     
    }else{
            pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opview.jsp");    
   
    }
       pRD.include(req,resp);
     }
     
       protected void doEdit(JBossRenderRequest req, JBossRenderResponse resp) throws IOException, PortletException
   {   System.out.println(opname+"EDIT");
    oid=req.getParameter("oid");  if(oid == null){oid="";}
           SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHHmmss");
           SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
          java.util.Date opdate=new java.util.Date();
        String  tmp="";
        tmp=formatter.format(opdate);
      
       
 
    String opmode="";
      opmode=  req.getParameter("opmode");
         System.out.println("opmode=" + opmode);
     if(opmode == null){opmode="";}
      resp.setProperty("opmode",opmode);
             resp.setContentType("text/html;charset=UTF-8");
             // resp.setContentType("text/html;charset=UTF-8");
             
           javax.portlet.PortletRequestDispatcher pRD =null;   
          
         org.gotdns.fedora.client.operationclient  home=new org.gotdns.fedora.client.operationclient();          
      if(opmode.equals("add")){
          pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opadd.jsp");        
      }    
      else if(opmode.equals("update")){
         pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opedit.jsp");          
      }
          else if(opmode.equals("updateup")){
              
             home.updateOperation(oid,opname,opdesc,oplink,disable);
              pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/ref.jsp");
         }
           else if(opmode.equals("del")){
            home.removeOperation(oid);
              pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/ref.jsp");
          
           }
     else if(opmode.equals("addup")){
              oid= sdf.format(opdate); 
             System.out.println(oid);
                System.out.println(opname);
                   System.out.println(opdesc);
                      System.out.println(opdate);   System.out.println(oplink);   System.out.println(disable);
       try{
                      home.insertOperation(oid,opname,opdesc,opdate,oplink,disable) ;
       }
       catch (Exception e){System.out.println(e.getMessage());}
       pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/ref.jsp");
     }
     else{
          pRD = this.getPortletContext().getRequestDispatcher( JSP_PATH + "/op/opview.jsp");        
     }
      
     
    
    
    
    
      pRD.include(req,resp);
    
     }
    
    
    
    
}



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031119#4031119

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031119



More information about the jboss-user mailing list