Hide a trigger put in the <fr:buttons> section

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Hide a trigger put in the <fr:buttons> section

r.pecori
Hi

I am using Liferay 4.2 PE.

I have a trigger in the <fr:buttons> section.

Can I hide it somehow? I tried adding the attribute relevant=false but it did not work.

Some solutions?
Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Jez
Have you created a binding for the trigger control?

If not I suggest, for "my-trigger":

1. In the Model, create an instance to hold control binding refs:
<xf:instance id="controls-instance">
    <controls>
        <my-trigger-control/>
    </controls>
</xf:instance>

2. and create bindings:
<xf:bind id="controls-binds" ref="instance('controls-instance')">
    <xf:bind id="my-trigger-control-bind" ref="my-trigger-control"
                    name="my-trigger-control" relevant="false"/>
</xf:bind>

3. In the body bind the control:
<xf:trigger id="my-trigger-control" bind="my-trigger-control-bind">
    ....
</xf:trigger>

Regards

jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

r.pecori
The trigger is not in the body but outside, in the buttons tag, where also the save tag of orbeon is put.

Are you sure it works all the same?

For setting false it works but what I really like to do is to put an expression in the relevant attribute and for now it does not work. Only works with fix false, not if I use an xpath conditional expression with if then else.
Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Jez
I would still recommend the binding approach; when I said "body" I was referring to the xhtml body, bindings are still in scope.

I use this approach to conditionally display buttons based on xpath expressions in the bind attributes.
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Alessandro  Vernet
Administrator
In reply to this post by r.pecori
As Jez suggested, you could bind the <fr:button> to a node in an instance, but since you want to hide the button based on some condition, you could also just have that condition in the ref expression, as:

<fr:button ref=".[condition]">

Where condition is an XPath expression that returns a boolean. If the expression returns false, then the whole expression will return an empty sequence, and thus the button will be hidden.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

r.pecori
Probably the problem is that I need to reference a parameter and cannot reach it.

I need something like "if ($parameter='value1') then true() else false()"

Must parameter be in the same instance of the trigger in the model?
Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Jez
Please find a working example at https://github.com/jeremyplace/temporary/blob/master/temp.xhtml.

This displays the my-trigger button when the "link" control contains 'true'.

I created it in FB with two controls "link" and "my-trigger" (with the visibility condition set), then:

1. Moved the my-trigger control into the fr:buttons section

The following two steps are optional, but are used so that the trigger element doesn't persist:

2. Moved the my-trigger instance element into a new run-time instance - "controls-instance"
3. Moved the my-trigger-bind binding into a new "controls-binds"

Regards

Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Alessandro  Vernet
Administrator
In reply to this post by r.pecori
r.pecori wrote
I need something like "if ($parameter='value1') then true() else false()"
Must parameter be in the same instance of the trigger in the model?
Where is that "parameter" declared? (And note that if you're talking of accessing a control named "parameter" through a variable, that won't work there, as this is only possible in binds.)

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

r.pecori
In reply to this post by Jez
Thank you , now it works :)
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

r.pecori
In reply to this post by Jez
Can I also bind the standar save button in the same way?

Can I also make so that clicking on save button it also redirects the page to another url  in this way?

I tried this:

 <fr:save-button id="saveClose" bind="saveClose-bind">
                                <xf:send submission="backSimple"/>
                            </fr:save-button>

but it does not work either the send to another page and the binding.
Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Jez
Yes you can bind the standard save button in the same way.

As to redirects, etc. You could either use a custom trigger, or configure the standard buttons along the lines of https://github.com/orbeon/orbeon-forms/wiki/Form-Runner:-Buttons-and-Processes
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

r.pecori
It does not work, I can not hide the standard save button in such a way.

Any advice?
Jez
Reply | Threaded
Open this post in threaded view
|

Re: Hide a trigger put in the <fr:buttons> section

Jez
Can't be sure why your's isn't working, could be you've modified the default fr-save-button.

I've updated the example with a conditional save button (link='true') at https://github.com/jeremyplace/temporary/blob/master/temp.xhtml.