Using if to control display of input box

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

Using if to control display of input box

ChrisSpeare
I have an XML document where some elements control the 'existance' of other elements.  This being, if the first xml element is one value, other xml elements are then included in the document, otherwise they are not required.  The XSD states that if one of these elements is in the document then it must be filled in, but the server I am sending to has rules stating if the first value is 'a' then the a list of elements are not required in the document.

So in a situation where I use a select1 that, if a certain value is selected, inserts new xml elements into the instance.  And logically when that value is not longer selected, removes those xml elements.  This works fine, and using a table I display all the fields.  This leaves me with a label for an input, but no input if the xml is not in the document - functional, but not very user friendly.

What I would prefer is the input displayed, but disabled if the xml is not in the document.

Who can this be achieved?
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

fl.schmitt(ops-users)
Hi Chris,

> What I would prefer is the input displayed, but disabled if the xml is not
> in the document.

You could use a xpath predicate in the ref attribute of the xforms:input
  that checks if the referenced node fulfills certain conditions:
<xforms:input ref="node[. != '']"> or something like that. Only if the
predicate evaluates to true, the xforms:input and its label are displayed.

HTH
florian





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

ChrisSpeare
Florian Schmitt-4 wrote
<xforms:input ref="node[. != '']"> or something like that. Only if the
predicate evaluates to true, the xforms:input and its label are displayed.
Little bit more than 'something like that' would be helpful.  I can right the form so that my table row is not displayed if the elements do not exist - this includes using output for the label with a count condition, and an xforms:input to reference the element of the XML.  This works until I use a select1 as this then displays a cutdown select box until the element is in the xml.

How can this be avoided?
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

Alessandro Vernet
Administrator
In reply to this post by ChrisSpeare
Chris,

On 6/1/07, ChrisSpeare <[hidden email]> wrote:
> So in a situation where I use a select1 that, if a certain value is
> selected, inserts new xml elements into the instance.  And logically when
> that value is not longer selected, removes those xml elements.  This works
> fine, and using a table I display all the fields.  This leaves me with a
> label for an input, but no input if the xml is not in the document -
> functional, but not very user friendly.

If the data is not there in the instance, i.e. if the node to which
the input is bound is really missing from the instance, then the input
should not be there. And you should not have a label either if you are
using xforms:label inside the input. Is this what you are doing?

> What I would prefer is the input displayed, but disabled if the xml is not
> in the document.

For the input to be shown (disabled or not), the element must be there
in the XML. But are you sure this is what you want to do? ;) Will the
input become enabled at some point? If it does, but there is no
element in the instance to hold the data, where would the data go?
There is some logic to the XForms rule that to have an form control
displayed in the page you need to have a node bound to that control in
the instance.

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

ChrisSpeare
Alessandro Vernet wrote
Will the input become enabled at some point? If it does, but there is no
element in the instance to hold the data, where would the data go?
This is a nice and annoying form.  There is a select1 at the top of the page to indciate who this form should be going to - 3 choices.  Each of these 3 except the common elements (therefore the mandatory) of the xml, but do not need/want the other elements.  As such these are stripped out until the selection is made.  At the poiint the recepient is made a series of insert/deletes are fired (<xforms:action ev:event="xforms-value-changed">...</xforms:action>).  This will then structure the xml document with the relevant fields it needs - this activating the input/select1 felds.

I am using outputs at the moment with a count(field_in_question) to display the labels > 0, and the input
is displaying / hiding when the element is there.  However the select1 always displays part of itself even if there is no element to bind to.  Can this be avoided?
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

fl.schmitt(ops-users)
In reply to this post by ChrisSpeare
ChrisSpeare schrieb:

> Little bit more than 'something like that' would be helpful.

I know :) - but it's hard to be more precise if there's no more
information about the instance data. It should simply be an illustration
how predicates could be used to manage the visibility of a xforms control.

 > I can right
> the form so that my table row is not displayed if the elements do not exist
> - this includes using output for the label with a count condition,

So you don't use the xforms:label to create the label? This would be
more comfortable, because if the surrounding xforms:input isn't
displayed, the xforms:label isn't, too.

 > and an
> xforms:input to reference the element of the XML.  This works until I use a
> select1 as this then displays a cutdown select box until the element is in
> the xml.

Sorry, but i don't understand. Maybe you could attach an example?

florian





--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

Alessandro Vernet
Administrator
In reply to this post by ChrisSpeare
On 6/5/07, ChrisSpeare <[hidden email]> wrote:
> I am using outputs at the moment with a count(field_in_question) to display
> the labels > 0, and the input
> is displaying / hiding when the element is there.  However the select1
> always displays part of itself even if there is no element to bind to.  Can
> this be avoided?

I don't think that should happen. This might be a bug. If a select
bound is bound to a "non-existent" element, then the select1,
including the label, hint, help, etc should not be displayed. Would
you have an example that we can run in the sandbox and that shows
this?

Alex
--
Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
http://www.orbeon.com/



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Using if to control display of input box

ChrisSpeare
I would, however after working with your example and merging it with mine I sorted it.  CSS!!!  In my css was a block relating to Select1 which made is visible consistantly.  Took this out and they disappear when not required.

ARRGGHHHH!!!

Sorted now however, cheers for all your help