欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
在Liferay Portal Professional里實(shí)現一個(gè)使用SOAP的portlet

使用的主要工具有:liferay-tomcat-3.1.0  axis-1.1。

下載得到這兩個(gè)工具的zip文件夾,分別解壓到兩個(gè)目錄里,

在環(huán)境變量里把TOMCAT_HOME, AXIS_HOME分別指向這兩個(gè)文件夾根目錄。

具體配置方法分別參考

Liferay

Axis

 

實(shí)現功能:在portlet里用SOAP訪(fǎng)問(wèn)Web Service,把得到的結果顯示在Portal界面

 

一、             配置Axis Server

1.  簡(jiǎn)單的服務(wù)程序,類(lèi)似hello world,如下

package com.kevinGQ.service

HelloService.java

public class HelloService

{

public String sayHello(String name)

{

        System.out.println("HelloService");

        return "Axis say hello to "+name;

}

};

先把%AXIS_HOME%/webapps/axis文件夾放到%TOMCAT_HOME%/webapps/下,把編譯好的HelloService.class放到axis/WEB-INF/classes里。

server-config.wsdd里添加如下XML片斷

<service name="HelloService" provider="java:RPC">

  <parameter name="allowedMethods" value="sayHello"/>

  <parameter name="className" value="com.kevinGQ.service.HelloService"/>

</service>

 

二、             寫(xiě)portlet的三個(gè)JSP文件(參照liferay里的weather portlet

1.         init.jsp

<%@ include file="/html/common/init.jsp" %>

<portlet:defineObjects/>

<%

PortletPreferences prefs = renderRequest.getPreferences();

String[] names = prefs.getValues("names", new String[0]);

%>

2.         view.jsp

<%@ include file="/html/portlet/hello/init.jsp" %>

 

<%@ page import="com.kevinGQ.portlet.hello.util.*" %>

<%@ page import="com.kevinGQ.portlet.hello.model.Hello" %>

Welcome!

<table border="0" cellpadding="0" cellspacing="4" width="100%">

       <tr>

              <td align="center">

                     <table border="0" cellpadding="0" cellspacing="0">

                            <tr>

                                   <td>

                                          <table border="0" cellpadding="0" cellspacing="0" width="100%">

                                          <%

                                          for(int i = 0; i < names.length; i++)

                                          {

                                                 Hello hello = HelloUtil.getHello(names[i]);

                                          %>

                                                 <tr>

                                                        <td>

                                                               <font size="1" color="#0000FF"><%= names[i] %></font>

                                                        </td>

                                                        <td align="right">

                                                               <font size="1" color="#FF0000">

                                                               <%

                                                               if(hello != null){

                                                               %>

                                                               <%= hello.getHello() %>

                                                               <%

                                                               }else{

                                                               %> 

                                                               <%= "null" %>

                                                               <%

                                                               }

                                                               %>

                                                               </font>

                                                        </td>

                                                 </tr>

                                          <%

                                          }

                                          %>

                                          </table>

                                   </td>

                            </tr>

                     </table>

              </td>

       </tr>

</table>

3     edit.jsp

<%@ include file="/html/portlet/hello/init.jsp" %>

 

<table cellpadding="4" cellspacing="0" border="0">

<form action="<portlet:actionURL><portlet:param name="struts_action" value="/hello/edit"/></portlet:actionURL>" method="post" name="<portlet:namespace />fm">

<input name="<portlet:namespace /><%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>">

       <tr>

              <td align="center">

                     <table border="0" cellpadding="0" cellspacing="0">

                    

              <c:if test="<%= SessionMessages.contains(renderRequest, portletConfig.getPortletName() + \".doEdit\") %>">

                                   <tr>

                                          <td>

                                                 <font class="gamma" size="1"><span class="gamma-pos-alert"><%= LanguageUtil.get(pageContext, "you-have-successfully-updated-your-preferences") %></span></font>

                                          </td>

                                   </tr>

                                   <tr>

                                          <br>

                                   </tr>

                            </c:if>

                           

                            <tr>

                                   <td>

                                          <font class="gamma" size="2"><%= LanguageUtil.get(pageContext,"") %> </font>

                                   </td>

                            </tr>

                           

                            <tr>

                                   <td>

                                          <textarea class="form-text" cols="70" name="<portlet:namespace/>names" rows="10" wrap="soft"><%= StringUtil.merge(names, "\n") %></textarea>

                                   </td>

                            </tr>

                            <tr>

                                   <td>

                                          <br>

                                   </td>

                            </tr>

                            <tr>

                                   <td align="center">

                                          <input type="button" value="<bean:message key="save-settings" />" onClick="submitForm(document.<portlet:namespace />fm);">

                                   </td>

                            </tr>

                     </table>

              </td>

       </tr>

       </form>

</table>

 

三、             相關(guān)的java文件

1. HelloUtil.java

package com.kevinGQ.portlet.hello.util;

 

import com.kevinGQ.portlet.hello.model.Hello;

import com.liferay.portal.util.WebCacheException;

import com.liferay.portal.util.WebCachePool;

import com.liferay.portal.util.WebCacheable;

import com.liferay.cache.model.Cache;

 

public class HelloUtil {

       public static Hello getHello(String name)

              throws WebCacheException{

              WebCacheable wc = new HelloConverter(name);

             

              Cache cache = WebCachePool.get(

                            HelloUtil.class.getName() + name, wc);

             

              return (Hello)cache.getObject();

       }

}

 

2.    HelloConverter.java 實(shí)現SOAP調用的主要類(lèi),加粗的代碼尤為重要,不寫(xiě)的話(huà)Axis Server端將會(huì )拋出錯誤。

package com.kevinGQ.portlet.hello.util;

 

import org.apache.axis.client.Call;

import org.apache.axis.client.Service;

import javax.xml.rpc.ParameterMode;

import org.apache.axis.encoding.XMLType;

 

import com.kevinGQ.portlet.hello.model.Hello;

import com.liferay.portal.util.WebCacheable;

import com.liferay.util.ConverterException;

import com.liferay.util.Time;

 

public class HelloConverter implements WebCacheable{

      

       HelloConverter(String name){

              _name = name;

       }

      

      

       public Object convert(String arg0) throws ConverterException {

              Hello hello = new Hello();

              try{

                     String endpoint = "http://localhost:80/axis/services/HelloService";

                     Service service = new Service();

                     Call call = (Call)service.createCall();

                     call.setSOAPActionURI("http://localhost:80/axis/services/HelloService#sayHello");

                     call.setTargetEndpointAddress(new java.net.URL(endpoint));

                     call.setOperationName("sayHello");

                     call.addParameter("param1", XMLType.XSD_STRING, ParameterMode.IN);

                     call.setReturnType(XMLType.XSD_STRING);

                     String ret = (String) call.invoke(new Object[]{_name});

                     hello.setHello(ret);

              }catch(Exception e){

                     throw new ConverterException(_name+" "+e.toString());

              }

              return hello;

       }

      

       public long getRefreshTime(){

              return _refreshTime;

       }

      

       private long _refreshTime = Time.DAY;

       private String _name;

}

 

3.         Hello.java

package com.kevinGQ.portlet.hello.model;

 

import java.io.Serializable;

 

public class Hello implements Serializable{

 

       public Hello(){

              //empty

       }

      

       public Hello(String hello){

              _hello = hello;

       }

      

       public String getHello(){

              return _hello;

       }

      

       public void setHello(String hello){

              _hello = hello;

       }

      

       private String _hello;

}

 

4.         EditPreferencesAction.java portletpreferences進(jìn)行處理的類(lèi)

package com.kevinGQ.portlet.hello.action;

 

import javax.portlet.ActionRequest;

import javax.portlet.ActionResponse;

import javax.portlet.PortletConfig;

import javax.portlet.RenderRequest;

import javax.portlet.RenderResponse;

import javax.portlet.PortletPreferences;

import javax.portlet.ValidatorException;

 

import org.apache.struts.action.ActionForm;

import org.apache.struts.action.ActionForward;

import org.apache.struts.action.ActionMapping;

 

import com.liferay.portal.struts.PortletAction;

import com.liferay.portal.util.Constants;

import com.liferay.util.ParamUtil;

import com.liferay.util.StringUtil;

import com.liferay.util.servlet.SessionErrors;

import com.liferay.util.servlet.SessionMessages;

 

public class EditPreferencesAction extends PortletAction{

       public void processAction(

                     ActionMapping mapping, ActionForm form, PortletConfig config,

                     ActionRequest req, ActionResponse res)

              throws Exception{

 

              String cmd = ParamUtil.getString(req, Constants.CMD);

 

              if(!cmd.equals(Constants.UPDATE)){

                     return;

              }

 

              PortletPreferences prefs = req.getPreferences();

 

              String[] names = StringUtil.split(

                     ParamUtil.getString(req, "names"), "\n");

 

              prefs.setValues("names", names);

 

              try {

                     prefs.store();

              }

              catch (ValidatorException ve) {

                     SessionErrors.add(req, ValidatorException.class.getName(), ve);

 

                     return;

              }

 

              SessionMessages.add(req, config.getPortletName() + ".doEdit");

       }

 

       public ActionForward render(

                     ActionMapping mapping, ActionForm form, PortletConfig config,

                     RenderRequest req, RenderResponse res)

              throws Exception {

 

              return mapping.findForward(getForward(req, "portlet.hello.edit"));

       }

}

 

以上四個(gè)類(lèi)經(jīng)過(guò)編譯后,放到%TOMCAT_HOME%/liferay/WEB-INF/classes/,如果沒(méi)有classes文件夾,可以自己新建一個(gè)。

 

四.相關(guān)部署描述文件的修改

1、修改portlet.xml

添加如下片斷

<portlet>

              <portlet-name>70</portlet-name>

              <display-name>Hello To</display-name>

              <portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>

              <init-param>

                     <name>edit-action</name>

                     <value>/hello/edit</value>

              </init-param>

              <init-param>

                     <name>view-action</name>

                     <value>/hello/view</value>

              </init-param>

              <expiration-cache>300</expiration-cache>

              <supports>

                     <mime-type>text/html</mime-type>

                     <portlet-mode>edit</portlet-mode>

              </supports>

              <resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>

              <portlet-preferences>

                     <preference>

                            <name>names</name>

                            <value>Kevin</value>

                            <value>John</value>

                     </preference>

              </portlet-preferences>

              <security-role-ref>

                     <role-name>Power User</role-name>

              </security-role-ref>

              <security-role-ref>

                     <role-name>User</role-name>

              </security-role-ref>

       </portlet>

 

2、修改struts-config.xml

<action-mapping>標簽下添加

<!-- Hello -->

              <action path="/hello/edit" type="com.kevinGQ.portlet.hello.action.EditPreferencesAction">

                     <forward name="portlet.hello.edit" path="portlet.hello.edit" />

              </action>

 

              <action path="/hello/view" forward="portlet.hello.view" />

 

3、修改liferay-portal.xml

<portlets>標簽下添加

<portlet id="70" struts-path="hello" narrow="true"/>

 

4、修改liferay-display.xml

<display>標簽下添加

<category name="category.myportlet">

              <portlet id="70"/>

</category>

 

5、修改tiles-defs.xml

<tiles-definitions>標簽下添加

<!-- Hello -->

       <definition name="portlet.hello.edit" extends="portlet_default">

              <put name="portlet_content" value="/portlet/hello/edit.jsp"/>

       </definition>

 

       <definition name="portlet.hello.view" extends="portlet_default">

              <put name="portlet_content" value="/portlet/hello/view.jsp" />

       </definition>

 

6、修改language.properties文件

由于liferay-tomcat-3.1.0里該文件是封裝在portal-ejb.jar文件里,所以需要在%TOMCAT_HOME%/liferay/WEB-INF/下創(chuàng )建content文件夾,并在里面創(chuàng )建properties.languange文件

 

javax.portlet.title.70=HelloTo

category.myportlet=MyPortlet

 

要實(shí)現portlet的國際化,還需要創(chuàng )建一系列的properties文件,比如說(shuō)簡(jiǎn)體中文的porperties_zh_CN.properties不過(guò)里面的中文用unicode編寫(xiě),就不在這里說(shuō)明了。

 

 

以上是我的實(shí)踐所得,所有代碼經(jīng)過(guò)實(shí)驗證實(shí)可行,這個(gè)例子簡(jiǎn)單而又有代表性,自己動(dòng)手寫(xiě)寫(xiě),受益匪淺。

本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
Liferay Portlet開(kāi)發(fā)簡(jiǎn)單說(shuō)明 - 我的博客 - 我的地盤(pán)我做主!
liferay二次開(kāi)發(fā)指南
JAVA客戶(hù)端通過(guò)SOAP與NET的WebServices進(jìn)行通信
Portlet應用開(kāi)發(fā)實(shí)例
基于 Struts 2 構建 WebSphere Portal 上的 Portlet 應用
ChartDirector與JFreeChart兩款主要web圖表工具調研報告
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久