cancel
Showing results for 
Search instead for 
Did you mean: 

htmlb:tray is expanded again when page is reloaded

0 Kudos

I have created several trays on one page. I did define the tray as follow.

<htmlb:tray id = "tray3"

title = "Declaratie gegevens"

design = "BORDERLESS"

width = "90%"

isCollapsed = " ">

</htmlb:tray>

When the user decides to collapse the tray everything is working fine. But as soon as a server event is triggered the tray is expanded again when the page is reloaded.

Of course, I did look at bsp program SBSPEXT_PHTMLB but this example is based on a flowlogic page. I'm building a bsp application based on the MVC model.

What kind of event can be triggered by the onCollapse of onExpand attribute of the htmlb:tray tag?

Please help me finding a solution to memorise whether or not the tray is collapsed or expanded before the server event is triggered.

Best regards,

Sander Pol

Accepted Solutions (1)

Accepted Solutions (1)

former_member181879
Active Contributor
0 Kudos

Yes, the question is very subtle. It has all to do about the truth (or more exactly about true), and the way ABAP as a language is structured to handle this.

We start with isX="false|true". But then some people somewhere said they like isX="0|1". (Don't ask me why, I never found out.) But, nearly everywhere in ABAP, we see things like isX=" |X", which is especially inforced with that nice "IF isX IS INITIAL." question.

So, never to be happy with one solution, our validator->toBoolean will accept "false|0| " to mean "no" and "true|1|X" for "yes". (We nearly added yes|no as well, but got lazy by then.)

So what did you write? <...isCollapsed = " ">, which means as much as isCollapsed="false", which translated gives us isExpanded="true". So, there it is black on white in your code: you request each time during rendering that the tray be rendered in expanded state.

If you wish the viewstate to be handled "automagically", just remove the isCollapsed attribute. If not specified, the tray should restore the value automatically and render its previous viewstate. (If not, we will call it a bug and exterminate it, just call us on the OSS hotline.)

All of the above should be independent of BSP pages versus views.

Welcome to forum!

++bcm

0 Kudos

First, I do apologize for leaving the attribute isCollapsed empty in this test case.

The attribute was filled like this "//model_trip/tray1". But then I red the help text where SAP explains that data binding is not supported on the htmlb:tray tag.

I did remove the isCollapsed attribute and tested again. Unfortunately, it did not work the way I expected. The page is loaded for the first time. All the trays are expanded. I did collapsed one of the trays. As soon as the pages reloads due to a server event that was triggered. The collapsed tray is expanded again!

What kind of event is or can be triggered by the onCollapse of onExpand attribute of the htmlb:tray tag?

Thanks for your input so far!

Best regards,

Sander Pol

former_member181879
Active Contributor
0 Kudos

None of the trays attributes support data binding.

Are you 100% sure that each tray has an unique ID?

This is a developer forum. Why not write less text, and a very small example. We accept maximum 25 lines of code. Then we can shoot some holes in it.

Here is my example and it worked as expected.


<%@page language="abap" %>
<%@extension name="htmlb" prefix="htmlb" %>

<htmlb:content design = "design2003">
 <htmlb:page>
  <htmlb:form>

   <htmlb:tray id="t1" title="t1" onExpand="e" onCollapse="c"/>

   <htmlb:tray id="t2" title="t2">
    <htmlb:trayBody>
     <htmlb:textView text="body of the tray" />
    </htmlb:trayBody>
   </htmlb:tray>

   <htmlb:tray id="t3" title="t3">
    <htmlb:trayBody>
     <htmlb:textView text="body of the tray" />
    </htmlb:trayBody>
   </htmlb:tray>

   <htmlb:button id="b1" text="HitMe!" onClick="go" />
  </htmlb:form>
 </htmlb:page>
</htmlb:content>

Paste this code onto a BSP page and play with. Try to reproduce your perceived problem with these few lines. Notice there is zero viewstate handling in this code. All onX event handlers are empty.

0 Kudos

Thanks a lot Brian!

It works.

Sander

Message was edited by: Sander Pol

daniel_humberg
Contributor
0 Kudos

Hi Sander, hi Bryan,

I have a similar problem because I use subcontroller.

I have subcontroller with a singe tray and i use the subcontroller on a view 3 times. The collapsing and expanding of the trays works, but after any event, all trays are expanded again.

subcontroller view


<htmlb:tray id="myTray" title = "<%=lv_t%>">
<htmlb:trayBody>
<htmlb:textView text = "<%=otr(XZY/abc)%>"/>
</htmlb:trayBody></htmlb:tray>

main view


<bsp:call url= "m.do"
          comp_id = "sc1" />
<bsp:call url= "m.do"
          comp_id = "sc2" />
<bsp:call url= "m.do"
          comp_id = "sc2" />

If you look at the code that is generated in the browser, you see that every control in the subctroller gets an id like this "sc2_myTray", so each Tray has a unique ID and no isCollapsed or isExpanded attribute.

What else do I have to check.

Answers (0)