cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional display in page fragments

Former Member
0 Kudos

Hi all,

I have to include a page fragment in one of the pages of my application.

Certain elements in the page fragment should be displayed based on certain conditions only.

How can this be done ?

Thanks in advance

Ananya

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Can we write Javascript in page fragment ? So that I can call a popup from a button in the fragment ?

athavanraja
Active Contributor
0 Kudos

yes you can do that.

page fragment code.

<%@page language="ABAP"%>

<%@ extension name="htmlb" prefix="htmlb" %>

<htmlb:button id ="b1"

text = "Click here"

onClientClick = "javascript:alert('test');"/>

and include this in your main page.

<%@ include file="<pagefragment>.htm" %>

Regards

Raja

Former Member
0 Kudos

Hi Ananya

I think its very much possible....

Just try it once....

and let us know...if you find some problem...

cheers:)

Mithlesh

Former Member
0 Kudos

Hi Mithilesh,

If i declare and set the flag in onCreate it is not accessible from the page fragment. So I declared the flag as boolean in the application class and assigned its value to the disabled property of the button in the page fragment.But it is giving runtime error.

Thanks

Ananya

Former Member
0 Kudos

HI Ananya...

Define HID_FLAG as a Page Attribute....of TYPE String.

And set its value at On Create....

It wont give you any Problem...

Cheers:)

Mithlesh

athavanraja
Active Contributor
0 Kudos

where the condition value would come from?

may be write the condition value to a serverside cookie and within you page fragment read the cookie value to decide whether to show ro not.

Mithles: its page fragments , so no page attributes.

Regards

Raja

Former Member
0 Kudos

HI Ananya...

You can definitely do this....

You have got two option..

1. If the Condition is known to you before displaying the page at the first attempt...

-


Define an attribute of STRING type say it HID_FLAG

-


inside the event ONCREATE...

On the basis of the condition set the flag to TRUE if want to display that region..otherwise..set it to FALSE..

Now inside the PAGE LAYOUT....

<% IF HID_FLAG = 'TRUE'. %>

Between this define the portion of your layout that you want to show on the basis of condition...

<% ENDIF. %>

2. Another option is that you dont know the condition initially....and the condition is defined on the ONINPUTPROCESSING.....

For this you can set that flag on the EVENT HANDLING....

Hope it solve your problem .....Otherwise do revert back....

Cheers:)

Mithlesh

Former Member
0 Kudos

Hi,

I meant that I donot want to display or enable all the elements in the page fragment.e.g. when included in one page one particular button of the fragment will be disabled..and so on..

Thanks

Ananya

Former Member
0 Kudos

Hi Ananya

If it is just the matter of disabling BUTTON, then you can do one thing ....Just set that HID_FLAG as described above.....and populate the DISABLED attribute of the button with HID_FLAG...like this..

disabled = <%= HID_FLAG %>

Hope it solve your problem..or do revert back....

Do reward points if found helpful...

Cheers:)

Mithlesh

Message was edited by: Mithlesh Jha

Former Member
0 Kudos

Hi,

sorry, can You please explain exactly, what You mean? I think, I don´t understand it at all...

Cheers