Skip to Content
author's profile photo Former Member
Former Member

Call Method from HTMLB

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

7 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2005 at 05:28 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 10:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 24, 2005 at 10:00 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 10:03 AM

    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-9c5c6504b89e

    regards,

    Martin

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 24, 2005 at 10:10 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 24, 2005 at 11:04 AM

    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?

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Nov 25, 2005 at 08:49 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.