on 08-06-2004 10:27 AM
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
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.
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
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
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.)
User | Count |
---|---|
94 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.