Re: Can toggle@case or case@selected be calculated?

Hi Adam,

Using @relevant is pretty much the way to do it. However, you will
need an extra instance to do this, since as you say, the data is the
same in both branches. switch/case is much more about a 'UI state'
that is not reflected in the model--rather like the position of a
scroll bar. If you want to actually reflect *model* state back into
the form then use @relevant.

So, to set it up, create two groups, bound to something like
"instance('i-control')/input" and "instance('i-control')/output". The
instance data would look something like this:

  <controls @state="input">
    <input />
    <output />
  </controls>

Then set up some bind statements so that these nodes are relevant
based on some rules, e.g.:

  <bind nodeset=""instance('i-control')">
    <bind id="ns-state" nodeset="@state" />
    <bind nodeset="input" relevant="../@state = 'input'" />
    <bind nodeset="output" relevant="../@state = 'output'" />
  </bind>

Now all you have to do to swap between the two (or how ever many you
like) groups is to set the value of $ns-state. This can be done either
by directly setting it, perhaps with a trigger (you might format the
triggers like tabs):

  <setvalue ev:action="toggle-input" bind="ns-state">input</setvalue>
  <setvalue ev:action="toggle-output" bind="ns-state">output</setvalue>

In your case you would use a bind calculation to set @state based on your data.

Once you've set the value everything else is done for you.

We use this technique a lot, to create complex, nested, tabbed dialogs.

All the best,

Mark


On 10/08/06, Flinton Adam <Adam.Flinton@cfh.nhs.uk> wrote:
>
> Dear All,
>
> I am trying to switch a form between being made up of a group of output
> elements & a group of input elements, dependant upoon a value contained
> in an instance which says if the data is readonly or not. The Value is
> carried in an element called OID_key & if it is 0 then it is readonly &
> if 1 then it is read/write.
>
> Basically what I want to say is "If OID_key = 0 then use the NoEdit Case
> & thus group of controls & if 1 then use the Edit case/group of
> controls"
>
>
> I have tried using a calculated value for both toggle@case and
> case@selected to no effect. See below for the 2 examples where the
> commented out part is the attempt at getting a calculated value.
>
>
> <xforms:toggle ev:event="xforms-ready" case="Edit"/>
> <!--<xforms:toggle ev:event="xforms-ready" case="if(OID_key =
> 0,NoEdit,Edit)"/>  -->
>
>
> <xforms:switch>
> <xforms:case id="Edit" selected="true">
> <!-- <xforms:case id="Edit" selected="if(OID_key = 0,false(),true())">
> -->
>
>
> Given I wish to keep the instance & simply display the information
> differently, the "relevant=" model switching is not of use so.....if
> there any way I can get an Xpath/function based value into either
> toggle@case or case@selected?
>
> Adam
>
>
>
> This e-mail is confidential and privileged. If you are not the intended recipient please accept our apologies; please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents: to do so is strictly prohibited and may be unlawful. Please inform us that this message has gone astray before deleting it. Thank you for your co-operation.
>
>
>
>
>


-- 
Mark Birbeck
CEO
x-port.net Ltd.

e: Mark.Birbeck@x-port.net
t: +44 (0) 20 7689 9232
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

Download our XForms processor from
http://www.formsPlayer.com/

Received on Thursday, 10 August 2006 12:59:38 UTC