How to toggle hideable panel from Java code instead of from async control

Is it possible to toggle a hideable panel when a command button is clicked?

I thought about using Invoke Script to toggle the panel but cannot figure out to toggle after the command control is clicked.

Hello,

Doesn’t the command button refresh the whole page on click?

You can try Event.waitUntiLoaded javascript event in this case.

or use an async command control and put the toggle javascript code in the corresponding “On Smth” box.

There are more possibilitites.

Can you explain a little more in depth what is your exact problem? Where is the pain point?

Best regards,
Vlad Turian

Where would I add the Event.waitUntilLoaded javascript?
I am using Designer 8.2.
The command button control has Client-Side Events tab. Under this tab, I see Click, Double Click, Mouse Down, etc; but none of these options are appropriate.
The jsf Form control has Client-Side Events tab as well. Under this tab, I see Click, …, Submit; but these options are not appropriate either.

Here’s my problem in detail.
I have one portlet with one form having toggle options and hideable panels. One of the hiedable panel had a async command button. When it is clicked, a webservice refresh() call is made, and current hidable panel is refreshed when the response is returned.
Now I need to use synchronous command button. When the sync com button is clicked, the webservice refresh() is made, and the page is refreshed. However, the last hideable panel is hidden this time.
I tried to set the toggle option by setting “Default Focus” property of Form Display - no hideable panel displayed although the toggle option is auto selected.

Hi Joy,

When I want to make sure some javascript code is executed before the page is loaded I use the following:

  • I add an “Script Block” in the component you know it will be refreshed. Usually for page refresh you can use the outermost component (the form)
  • I add the following code in the Script Block

Event.waitUntilLoaded(function(){ 
//your code goes here
}); 

However please note that this code will execute every time the page is refreshed (not just when it is refreshed as a part of your webservice action).

Hope it helps,
Vlad Turian