cancel
Showing results for 
Search instead for 
Did you mean: 

Pls help! question on sample jsp...

Former Member
0 Kudos

Hi, I would like to understand this sample JSP better (yetanother.jsp from the TemplateJSPDynPage.par file downloaded from "Getting Started Section" of PDK inside my EP6.0). I have inserted 4 questions and statements(that I hope you can verify as correct or not) inside the code that I hope you can answer, they are marked by <b>"*** ***"</b>. Thank you so much for your help !

Thanks again,

Baggett.

<b><!-- #1 *** *** 'tagLib' is the folder containing tag(hbj) that I will use, am I right? Also, where is this tag(hbj) located? I went to my taglib folder(<ProjectName>/dist/PORTAL-INF/taglib), but nothing is there. Is 'hbj' just a name I can create for the tag?--> </b>

<%@ taglib uri="tagLib" prefix="hbj" %>

<b><!-- #2 *** *** 'myBean' is the name I create for the bean or class(bean.TemplateJSPDynPageBean) that I will use, am I right? What is scope? A bean is just a java class. Do you know where the bean.TemplateJSPDynPageBean is located on my machine? --></b><jsp:useBean id="myBean" scope="application" class="bean.TemplateJSPDynPageBean" />

<hbj:content id="myContext" >

<hbj:page title="Yet Another Page">

<hbj:form>

<hbj:gridLayout>

<b><!-- #3 *** *** Can you please provide info on each of these elements below: hbj, gridLayoutCell, rowIndex, columnIndex, what they are or do, how are they related? --></b> <hbj:gridLayoutCell rowIndex="1" columnIndex="1">

<b><!-- #4 *** *** myTextView is an instance of textView, setText is a method inside textView java class, and getText is a method inside myBean(TemplateJSPDynPageBean class), am I right?--></b>

<hbj:textView id="myTextView">

<% myTextView.setText(myBean.getText()); %>

</hbj:textView>

</hbj:gridLayoutCell>

<hbj:gridLayoutCell rowIndex="2" columnIndex="1">

<hbj:button id="button"

text="Yet Another Button"

onClick="onYetAnotherStateButtonClicked"/>

</hbj:gridLayoutCell>

</hbj:gridLayout>

</hbj:form>

</hbj:page>

</hbj:content>

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Soran,

here are some answers:

1. The htmlb taglib is not located in your project folder. You can include it via a sharing reference in the portalapp.xml of your project.

<application-config>

<property name="SharingReference" value="htmlb/>

</application-config>

You also define the taglib uri for a component in the portalapp.xml.

<component-profile>

<property name="tlhtmlb" value="/SERVICE/com.sap.portal.htmlb/taglib/htmlb.tld "/></component-profile>

In your jsp you have to define the prefix (hbj) of the taglib:

<%@ taglib uri="prt:taglib:tlhtmlb" prefix="hbj" %>

2. Beans are used to comunicate between a java class (the controller) and the JSP (the view).

The scope of the bean defines, in wich container it is stored and it defines the lifetime of a bean.

In my projects we are using the "session" scope for our beans as the "application" scope is not reliable enough.

On java side you have to store the bean int the session:

HttpSession session = request.getServletRequest().getSession();

session.setAttribute("myBean", myBean);

on JSP side You can read the bean from the session scope:

<jsp:useBean id="PageModel" scope="session" class="bean.TemplateJSPDynPageBean"/>

3. See the online docu for htmlb in the portal.

You need the PDK business package installed in your portal and the java developer role assigned.

4. Yes you are right

Best regards

Frank