Monday, May 02, 2005

SAP Portals Continued

Now that we have downloaded and installed the Eclipse plug-in for SAP portal development, we can proceed with creating a project. Before we start, we need to decide which approach we plan on taking. SAP provides two different methods, PageContext and DynPage. We are going to use the DynPage approach because it is easier to integrate JSPs using the DynPage methodology.

To start, we go to the Eclipse menu and select File>New>Other... which will bring up a dialog box. The SAP plug-in has added a new choice, "Portal Application". Select this and two items will become available on the right side of the dialog box, "Create a portal application project" and "Create a new portal application object". Select "create a project," enter a name and directory for the project, and then push the "Finish" button. A new project is created which includes most of the jar files you will need. Two additional jar files need to be added because we are going to use the DynPage methodology, htmlb.jar and com.sap.portal.htmlbridge.jar. Add these to the project.

In order to write a DynPage, two classes are required. First, you need to create a launcher class. The launcher (or controller) must extend the SAP class, PageProcessorComponent and must provide an implementation for the abstract method getPage. The getPage method must return a DynPage object. Here is the beginning of our "Hello World" portlet:

package main;

import com.sapportals.portal.htmlb.page.*;
import com.sapportals.htmlb.page.*;
import com.sapportals.htmlb.*;
import com.sapportals.htmlb.enum.*;

public class TestController extends PageProcessorComponent {
 
 public DynPage getPage() {
  return new TestDynPage();
 }

The next step is to provide a DynPage. In this example, in order to keep it simple, we will not use a JSP but will generate HTML directly from our DynPage. The TestDynPage will be an inner class of the TestController. TestDynPage will extend DynPage and must provide an implementation for the three abstract methods, doInitialization, doProcessAfterInput, and doProcessBeforeOutput. We will provide empty implementations for the first two. The doInitialization method is invoked only the first time the user enters the page. The doProcessBeforeOutput is invoked after doInitialization the first time and after the doProcessAfterInput method on subsequent calls.

There are two other classes that we need to worry about. First, the Form class that provides us with the area of the screen that we can write on. The second class is the TextView class which is one of the SAP provided HTML-Business (htmlb) classes. These classes work in a very similar way to the JSF classes in that they automatically generate HTML and provide an event based methodology to respond to user actions. We will worry about events in our next attempt. In this example, we will simply send some text to the screen.

The steps are fairly simple. First we get the Form from the current DynPage. Next we create a TextView, add some text to it, and then add it to the Form. And that is it. All that is left is to look at the rest of the code:

 public static class TestDynPage extends DynPage {
  
  public void doInitialization() {}

  public void doProcessAfterInput() throws PageException {}

  public void doProcessBeforeOutput() throws PageException {
   Form aForm = this.getForm();
   TextView label = new TextView();
   label.setText("Hello World!");
   label.setDesign(TextViewDesign.LABEL);
   aForm.addComponent(label);
  }
 }
}

1 comment:

sexy said...

情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,情趣,情趣,情趣用品,情趣用品,情趣,情趣,A片,A片,情色,A片,A片,情色,A片,A片,情趣用品,A片,情趣用品,A片,情趣用品,a片,情趣用品A片,A片,AV女優,色情,成人,做愛,情色,AIO,視訊聊天室,SEX,聊天室,自拍,AV,情色,成人,情色,aio,sex,成人,情色免費A片,美女視訊,情色交友,免費AV,色情網站,辣妹視訊,美女交友,色情影片,成人影片,成人網站,H漫,18成人,成人圖片,成人漫畫,情色網,日本A片,免費A片下載,性愛情色文學,色情A片,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色視訊,免費成人影片,視訊交友,視訊聊天,言情小說,愛情小說,AV片,A漫,AVDVD,情色論壇,視訊美女,AV成人網,成人交友,成人電影,成人貼圖,成人小說,成人文章,成人圖片區,成人遊戲,愛情公寓,情色貼圖,色情小說,情色小說,成人論壇a片下載,線上a片,av女優,av,成人電影,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,成人網站,自拍,尋夢園聊天室A片,A片,A片下載,做愛,成人電影,.18成人,日本A片,情色小說,情色電影,成人影城,自拍,情色論壇,成人論壇,情色貼圖,情色,免費A片,成人,成人網站,成人圖片,AV女優,成人光碟,色情,色情影片,免費A片下載,SEX,AV,色情網站,本土自拍,性愛,成人影片,情色文學,成人文章,成人圖片區,成人貼圖