cancel
Showing results for 
Search instead for 
Did you mean: 

BSP Extension Composite Element with Body

Former Member
0 Kudos

Hello,

I created an own BSP Extension element "myLink" which should be a composite element containing HTMLB:LINK element.

The myLink-DO_AT_BEGINNING looks like follows:

-

-


DATA: orgLink TYPE REF TO CL_HTMLB_LINK.

orgLink = CL_HTMLB_LINK=>FACTORY( id = id

reference = reference

text = text ).

WHILE m_page_context->element_process( element = orgLink )

EQ CO_ELEMENT_CONTINUE.

ENDWHILE.

rc = CO_ELEMENT_CONTINUE.

-

-


This works fine for - Tag (coming from DO_AT_END of HTMLB:LINK) is inserted before the body of my element.

It is possible to add the text "LinkText" as a literal in the WHILE - loop. But: I don´t find a way to do this dynamically! The body of a myExtension:myLink can contain text, images, other BSP elements. How can I access this during runtime so that I can supply the BODY-parameter of method "element_process"? How to do this? Or isn´t this the solution for this problem?

Maybe I´m to silly to see obvious things. I read a lot of articles about composite BSP elements - but I didn´t find an example handling dynamic or unknown element-bodies.

Thank you for any help,

best regards,

Stefan

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Stefan,

look at the implementation of

CL_HTMLB_LINK->IF_BSP_ELEMENT~DO_AT_END

so you have to implement your own do_at_end.

Don't forget to check at bsp-element attributes that the element-content attribute is checked at bsp-elements & html.

Regards

Former Member
0 Kudos

Hello Sebastian,

wow, this was really a fast answer. I checked your proposal, but I´m no not sure if this solves my problem.

After performing

-

-


orgLink = CL_HTMLB_LINK=>FACTORY( id = id

reference = reference

text = text ).

WHILE m_page_context->element_process( element = orgLink )

EQ CO_ELEMENT_CONTINUE.

ENDWHILE.

-

-


the CL_HTMLB_LINK~DO_AT_END was performed and has already inserted the "</a>" tag. So it will not help if I change the DO_AT_END method of my extension.

I want to use the m_page_context->element_process method to process the "wrapped" HTMLB-element (HTMLB:LINK in my example) and do not want to copy all methods and attribues to an own BSP extension. I think for this reason the optional "BODY" - paramenter of m_page_context->element_process method is for. But I´ve no idea how to supply it.

Best regards,

Stefan Obermeier

Former Member
0 Kudos

Hi Stefen,

If you want te text to be inserted before the closing tag then you need to add some code to the while loop in your code.

Check this:

orgLink = CL_HTMLB_LINK=>FACTORY( id = id

reference = reference

text = text ).

WHILE m_page_context->element_process( element = orgLink )

EQ CO_ELEMENT_CONTINUE.

DATA: out TYPE REF TO IF_BSP_WRITER.

out = m_page_context->get_out( ).

out->print_string( 'Hello' ).

ENDWHILE.

-


This will add the text "Hello" between the ending and closing tags.

Hope it'll help.

Cheers

Ankur

maximilian_schaufler
Active Contributor
0 Kudos

Hi Stefan,

I understand what you want to achieve - maybe you have to play around with the "delegated" attributes/methods to really achieve what you want using HMTLB:LINK from within your element this way.

Here is what I did for a similar problem: I created my own tooltip-on-mouseover extension, which can be wrapped around any kind of other elements that are placed in the tooltip element body.

I also have a special attribute in this element, "contentAsLink". If this attribute is set, I render the opening href HTML tag (<a>) in method DO_AT_BEGINNING, and the closing tag (</a>) in DO_AT_END. Not the best way if you really want to stick with HTMLB everywhere, but it's nice and easy.

Here is the precise opening tag I use:

<a class="urLnkFunction" href="javascript:void(0);">

Hope this helps you to find a solution for your needs.

Cheers,

Max

0 Kudos

Hello Stefan,

the problem is the WHILE Statement in your extension. What you have to do is:

1. declare orgLink as Instance Private (or Protected) Attribute at your (extension) class

2. instead of

WHILE m_page_context->element_process( element = orgLink )

EQ CO_ELEMENT_CONTINUE. ENDWHILE.

please use

m_page_context->element_process( element = orgLink ).

in DO_AT_BEGINNING and a second

m_page_context->element_process( element = orgLink ).

in DO_AT_END

So the opening tag will be rendered in DO_AT_BEGINNING and the closing tag in DO_AT_END.

Hth, Bernhard

Former Member
0 Kudos

Hello Ankur,

thank you for your answer. However, this means that you "know" the text within the tags ("Hello" in your example).

But this is normally defined in BSP-layout page and a topic of (dynamic) change. How can this be handled?

Best regards,

Stefan

Former Member
0 Kudos

Hello Bernhard,

thank you for this solution. It works fine for all examples I´ve tested.

The only thing which is not clear for me is that I´ve read that BSP-element can interate over the body and that this requires to have this WHILE-loop.

Best regards,

Stefan Obermeier

Answers (0)