0
votes

I have an application that runs a timer script that does a click on an action button when it times out. The action button is hidden by display:none. on the action button I do a partial refresh on panelButtonBar from the onClick event. This all works great except part of what the onClick event does is sets a viewScope variable based on the condition of the document. The viewScope variable is vsIsLocked and can be either true or false. If the value is true I don't want the panelButtonBar refreshed. I created a field that does nothing called dummyField and added the following to the definition of the partial refresh:

(viewScope.get("vsIsLocked")) ? "dummyField" : "panelButtonBar"

by putting dBar.info statements in the code that is by the onClick of the action Button I know that it is running on schedule, I also know that the value of vsIsLocked has changed from true to false, but the panelButtonBar does not refresh. As I said if I take the conditional statement out and just do a partial refresh of panelButtonBar the refresh works, the conditional partial refresh does not. I believe my js correct. I tried:

(viewScope.get("vsIsLocked")) ? "" : "panelButtonBar"

but then the partial refresh seems to run as a total refresh.

1
Could you put up a jsfiddle to illustrate this further? Greetings from one Bill F. to another. - Willy
@BillF. to another - not sure what you mean. Everything works the code for a conditional refresh. In the dialog for Select the Element to refresh I select Secfify element ID and then instead of entering panelButtonBar and select the little diamond and enter the js above. it is pretty simple vsIsLocked is either true or false if it is true refresh the dummyField that really does nothing (just a place holder) if it is false refresh panelButtonBar. I could leave it always doing the partial refresh on panelButtonBar but when is true there is no reason to do so. - Bill F
He's referring to jsfiddle.net which is a great way to test and share purely client-side web code. Since this particular issue is server-side behavior, that's not applicable in this instance, but it's a good tool to be aware of. - Tim Tripcony
P.S. Since event handlers are also components, they support the rendered attribute. If the button you're hiding via CSS is inside your partial refresh target, and you compute the rendered attribute of its event handler, when you programmatically "click" the button, nothing will happen if rendered evaluates to false, because the click event will not have been registered. - Tim Tripcony
@Tim all of the components in this case are "hidden" by using display:none NOT the "rendered" property. Everything works as expected if I put "panelButtonBar" explicitly in the partialrefresh property, except I get a whole bunch of needless partial refrshes done. Seems to revolve around the formula for a partial refresh. The onClick event sets vsIsLocked correctly but the partial refresh formula does not seem to fire, at least not correctly. - Bill F

1 Answers

0
votes

You might be a little caught in "what gets refreshed when". The (viewScope.get("vsIsLocked")) ? "dummyField" : "panelButtonBar" sits in your hidden button and gets computed when that button refreshes. When you "press" the button however you either refresh the dummyField or the panelButtonBar, but not the button itself. So your condition doesn't get evaluated.

You can try put your hidden button into the panelButtonBar or target your refresh at something that includes both.

Update
The target property is only evaluated on page load, so you would need to have one button each for your refresh targets hard wired and compute the rendered property. So when it refreshes a different button is sent to the browser each time. You could use a custom control with a parameter array for the targets, so you only have one control in your UI