cancel
Showing results for 
Search instead for 
Did you mean: 

Call Method from HTMLB

Former Member
0 Kudos

Hi @ all,

I'm new to HTMLB JspDynpages. I've started with building pages with buttons etc. But now I want to create a Isolated HTML Container. If I'm writing the url for that container in the HTMLB tag, it runs fine.

<hbj:isolatedHtmlContainer id="isohtmlCont"
        width="400"
        height="200"
	srcUrl="www.sap.com"
	scrolling="AUTO"
	bordered="true"
	tooltip="An isolated container"
>

But now I want the link dynamic.

How can I call a get method that gives me that dynamic

url for the srcUrl parameter?

Regards,

Dennis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Dennis,

I found a small mistake in your code..

Instead of putting the bean in IPortalComponentContext, try putting it in IPortalComponentProfile. To do it, in your code, just replace

myContext.putValue("databean", databean); with

myProfile.putValue("databean", databean);

The scope 'application' of a bean refers to IPortalComponentProfile.

But, you can very well go with what Ganesh said, if you have an netWeaver Developer Studio. It is even simple and generates codes automatically to use the bean each scope...

regards

Vijay.K

darrell_merryweather
Active Contributor
0 Kudos

Hi

Just so that you know, you shouldn't be storing the bean in the IPortalComponentProfile any more. The reason for this is because the IPortalComponentProfile will get garbage collected, which means that on occasions you will get NullPointerExceptions thrown when trying to retrieve the bean from the profile. The recommended place to store the bean is now in the IPortalComponentSession

IPortalComponentSession session = request.getComponentSession();

session.putValue("myBean", myBean);

I hope this helps

Darrell

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi all together,

thank you all for the help.

I will check this in my coding.

At this time, I'm storing the bean in the context and in works fine. But maybe storing the content in the session would be a good idea.

Regards,

Dennis

Former Member
0 Kudos

Hi,

thank tou all for the help.

I've used the code you all send me. As far as I understand, I have to create a Java class which ist my Databean and includes the private attribute url with setter and getter.

So far so good, now I have the method doInitialization()

There I do this first:

request = (IPortalComponentRequest) getRequest();
		myContext = request.getComponentContext();
		myProfile = myContext.getProfile();

the next step is:

myContext.putValue("dataBean",dataBean);

If I underestood right, I now have bound the object "dataBean" to the conetxt. And if I will write the line:

<jsp:useBean id="dataBean" scope="application" class="com.aga.silentprint.DataBean"

into my jsp. I can call the method of the dataBean in the Jsp like that:

srcUrl="<%= dataBean.getUrl()%>"

But if I call it, the url is empty. do I have to do anything else that the conetxt is bound to the bean, or didn't I understand it?

Former Member
0 Kudos

hi,

i think you missed few steps while creating the JSPdynpage by which you should actually link the bean with the dynpage. when you name the dynpage and jsp page while creating the JSP dynpage in the template, click the next button.

There ll be a radiobutton with an optin <b>Generate Bean statements</b>

under which there will be Bean name, Bean scope , Bean scope and package to place the Bean class.

you can select the scope of the Bean as request or session or application.

It is only now that your portal component is associated with your Bean class. It is not that you create a Bean class separately and try to link with your JSP dynpage.

Hope it helps..

regards,

Ganesh.N

pravesh_verma
Active Contributor
0 Kudos

Hi Dennis,

You can use Bean to get the value of the link. You just have to write a extra java bean which will be populated at run time. It must have a method of getURL and setURL. These values can be set at run time and get in the values in JSP page. Please see the dummy code below.

You have to add the tag of usebean in the starting of the code. please have a lokk to this dummy example:

<jsp:useBean 
	id="myBean" 
	scope="application" 
	class="com.hcl.urlbean" 
	/>

Here <b>class</b> is the <b>package.class_name</b> of the bean. I have assumed the bean name to be: <b>urlbean</b>, and package name to be: <b>com.hcl</b>

And while accessing the value of the url you can write as:


<hbj:isolatedHtmlContainer id="isohtmlCont"          
width="400"        
height="200"	
srcUrl="<%=myBean.getURL()%>"	
scrolling="AUTO"	
bordered="true"	
tooltip="An isolated container">

I hope this helps you.

Regards

Pravesh

PS: Please consider rewarding points if helpful.

Former Member
0 Kudos

Hi Dennis,

please have a look at the following articel. It describes how to use java beans in htmlb.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/cefed690-0201-0010-8480-9c5...

regards,

Martin

darrell_merryweather
Active Contributor
0 Kudos

You should be able to use

<% String myurl = "https://www.sdn.sap.com";%>

<hbj:isolatedHtmlContainer id="isohtmlCont"

width="400"

height="200"

srcUrl="www.sap.com"

scrolling="AUTO"

bordered="true"

tooltip="An isolated container"

>

<%isohtmlCont.setSrcURL(myurl);%>

</hbj:isolatedHtmlContainer>

I hope this helps

D

Former Member
0 Kudos

hi dennis,

you can use a bean class to get the dynamic url content as,

srcUrl="<%= myBean.getUrl()%>"

where myBean is the id of the Bean in your JSP. getUrl() is the method in the bean class.

Hope this helps.

regards,

Ganesh.N