cancel
Showing results for 
Search instead for 
Did you mean: 

BSP Extensions: method implementation

Former Member
0 Kudos

Hello together,

I am currently trying to implement custom BSP Extensions (taglibs). Almost everything works, I can use my element, it is also shown in the Tag browser in SE80, but I really have no idea on how to implement the rendering.

The documentation exactly leaves out the part on how to actually draw the custom HTML, I can only find info on how to manipulate the element's given content within the BSP. So far, I have overriden (redefined?) the methods DO_AT_BEGINNING and DO_AT_END and somewhere I found that M_OUT attrib. When calling m_out->print_string( 'Hello' ), nothing happens

Has anyone some example coding on how to do the actual drawing of the component? I have taken a look on the standard BSP extensions in HTMLB (like button and so), but could nowhere find the actual rendering stuff.

Please help me

Thanks in advance for any hints or samples.

Greetings, Timo

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

This is a good topic, comes back often I think

Here are some links you should check out...

<a href="/people/brian.mckellar/blog/2004/07/28/bsp-programming-writing-composite-elements">BSP Programming: Writing Composite Elements</a>

And of course the basics...

<a href="/people/brian.mckellar/blog/2004/06/11/bsp-trouble-shooting-getting-help">BSP Trouble Shooting: Getting Help</a>

<a href="/people/brian.mckellar/blog/2003/10/31/bsp-programming-htmlb-tableview-iterator">BSP Programming: HTMLB TableView Iterator</a>

Here is a code sample of doing something in the <b>IF_BSP_ELEMENT~DO_AT_BEGINNING</b>


DATA: txt TYPE REF TO CL_HTMLB_TEXTVIEW.

txt ?= cl_htmlb_textView=>factory( text = tmp ).

while m_page_context->element_process( element = txt ) =
co_element_continue.
endwhile.

The Weblogs were a great help to me when I got started. I've since created about 20 or so BSP Extension/Elements.

Former Member
0 Kudos

Hello Craig,

Thank you for the quick response. Yes, I have tried out the blogs before and also found that one referenced in your second link. I also managed to implement TableView Iterators and it works quite fine now.

I will try everything out and write back on it here.

Thank you!

Timo

Former Member
0 Kudos

Good luck look forward to hearing the outcome!

Former Member
0 Kudos

Rehi,

I think i will use a page fragment instead of an extension I wanted to implement a reusable search help but am trying now for two days to get it working. Sadly, I have a tight schedule and must cancel that now.

I think i will try it again in the future.

Right now it seems that the events are not even handled. When lookin into the HTML source of the BSP, the tag does not even cause a blank or newline. Cos it is ommitted, this indicates that it is recognised by the runtime.

BTW: i do my event coding by right-clicking on the method of the IF_BSP_ELEMENT of the element class and chosing redefine. Is that right thus? Only then i can edit w/o doing a modification. I think this redefinition is a complete overriding / implementation of the interface's method?!?

Thank you anyhow,

Timo

Former Member
0 Kudos

The way I've done it is to create one then use the redefine for the DO_AT_BEGINNING just like Thomas Jung stated in his weblog (link see above)

What's your code?? post it maybe my eyes will see something you are not due to your deadline and all.

Former Member
0 Kudos

Hello Craig,

This is a raw version, I tried it in various combinations and from simple to kinda complex. However, in neither case anything reaches within the generated BSP, not even a space or so. If i leave out the <% extension ...%>, the elements got printed, otherwise not, thus, runtime gets it.

The class has a custom superclass that is derived from CL+BSP_ELEMENT.

method IF_BSP_ELEMENT~DO_AT_BEGINNING .

*TRY.

*CALL METHOD SUPER->IF_BSP_ELEMENT~DO_AT_BEGINNING.

  • RECEIVING

  • RC = CO_ELEMENT_CONTINUE

  • .

*ENDTRY.

  • DATA: txt TYPE REF TO CL_HTMLB_TEXTVIEW.

  • txt ?= cl_htmlb_textView=>factory( text = 'hello' ).

  • while m_page_context->element_process( element = txt ) =

  • co_element_continue.

  • endwhile.

DATA: out TYPE REF TO IF_BSP_WRITER.

out = m_page_context->GET_OUT( ).

out->PRINT_STRING( `body string` ).

endmethod.

Thanks again for your offer to help,

Timo

Former Member
0 Kudos

I have a Class which has the super class: CL_BSP_ELEMENT

I then redefine the IF_BSP_ELEMENT~DO_AT_BEGINNING method


method IF_BSP_ELEMENT~DO_AT_BEGINNING .
* Data declaration

  DATA: outstream TYPE REF TO if_bsp_writer.
  DATA: txt TYPE REF TO CL_HTMLB_TEXTVIEW.
  DATA: help_string TYPE STRING.

* Assigning the output stream, if I want to use it
  outstream = me->if_bsp_element~m_page_context->get_out( ).

* Display HTMLB textView
 txt ?= cl_htmlb_textView=>factory( text = 'hello' ).

 while m_page_context->element_process( element = txt ) =
 co_element_continue.
 endwhile.

 CONCATENATE 
   '<br>'
   '<br>'
   'Or this is output as well'
 INTO help_string.
 outstream->print_string( help_string ).

*Close
  rc = me->co_element_done.
endmethod.

Former Member
0 Kudos

Rehi Craig,

You did not promise too less! I created a new initial element and redefined that method again. W/ your code, it now works like a charm. However, when using this in the "old" elememtn, nothing works....

Strange, cause both elements have the same options and structure (e.g. both have a generated parental class). I really cannot sport the diff, but i am shure there is kind of typo or so somewhere in it.

So, now I know

a) how to reuse existing BSP extensions in a custom one (composing) as well as

b) how to implement custom pure HTML in it

That is success!

Really thank your for the good example posted here, I think it will be useful for others as well!

Greetings, Timo

Former Member
0 Kudos

Make sure you mark this message solved then so people can find it quicker in the future and I can remember where I put a code sample

Glad I could help!

Former Member
0 Kudos

...and please don't forget to give Craig the contribution reward points he earns for his tremendous effort.

Regards

Stefan

Former Member
0 Kudos

> Make sure you mark this message solved then so people

> can find it quicker in the future and I can remember

> where I put a code sample

Okay, already done.

>

> Glad I could help!

Me also

Thanks and bye, Timo

Former Member
0 Kudos

> ...and please don't forget to give Craig the

> contribution reward points he earns for his

> tremendous effort.

Good you said it, missed that feature (only know it in Sun Forum...).

Okay, also done

>

> Regards

> Stefan

Greetings,

Timo

Peter_Inotai
Active Contributor
0 Kudos

There are some detailed examples in Karl Kessler's articles:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/faster%20development%20and%20greater%20flexibility%20for%20your%20web%20applications">Development and Greater Flexibility for Your Web Applications</a>

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sapportals.km.docs/documents/a1-8-4/build%20more%20powerful%20web%20applications%20in%20less%20time%20with%20bsp%20extensions%20and%20the%20mvc%20model.pdf">Build More Powerful Web Applications...</a>

Peter

former_member181879
Active Contributor
0 Kudos

Let me answer for you the final part of the puzzle.

You write:

<i><% extension ...%>, the elements got printed, otherwise</i>

When we have a BSP page, we can have actually XML on the page. So the pre-processor sees something such as this:


   <myLib:myTag a1 = "v1">
   </myLib:myTag>

It is going to say, aha, here we have some nice XML code coming down the pipe. Good for you. This XML is now placed as a string (what more is XML than a string?) and send to the browser. So if you do a view source in the browser, you should see your XML.

In summary, we aim to please, and XML is high on our list things we like.

So what is a man to do? You must write onto the page:


<%@extension name="myFirstLib" prefix="myLib"%>

This line the pre-compiler eats. And then after a moment of silence, it accepts that you don't like XML. Anything that now just looks like "<myLib:*>" is immediately understood to be a tag. Thus the compiler is informed, and it will generate the correct ABAP code to call this tag.

And this pre-compiler believes in perfection: mylib is NOT equal to myLib. It is case sensitive!

In summary: one slip of the finger, and you tag gets seen as XML and rendered out as raw string.

(With a syntax check step, and not a compile step, you will also get a warning about this. Just to be a little helpful.)

Answers (0)