Evaluate instance data to detemine initial state of form

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

Evaluate instance data to detemine initial state of form

Chris Gamache
I can't figure out how to toggle switch cases on load... I've been
working on this example for several days and I can't seem to get that
last detail to work. If I could evaluate an XPath expression in
@selected in case, it'd be quite simple.

Here's a simple example of a form missing that little incomplete
facet... I want the form to output 'You chose "Baz"' as it's initial
state. Thanks for your help!


<h:html
 xmlns:h="http://www.w3.org/1999/xhtml"
 xmlns:xforms="http://www.w3.org/2002/xforms"
 xmlns:ev="http://www.w3.org/2001/xml-events"
>
        <h:head>
                <xforms:model>
                        <xforms:instance xmlns="">
                                <foo>baz</foo>
                        </xforms:instance>
                </xforms:model>
                <h:title>Foo</h:title>
        </h:head>

        <h:body>

                <xforms:switch>

                        <xforms:select1 ref="/foo">
                                <xforms:label>Choose your metasyntactic varaible:</xforms:label>
                                <xforms:item>
                                        <xforms:label>Bar</xforms:label>
                                        <xforms:value>bar</xforms:value>
                                        <xforms:action ev:event="xforms-select">
                                                <xforms:toggle case="case-bar" />
                                        </xforms:action>
                                </xforms:item>
                                <xforms:item>
                                        <xforms:label>Baz</xforms:label>
                                        <xforms:value>baz</xforms:value>
                                        <xforms:action ev:event="xforms-select">
                                                <xforms:toggle case="case-baz" />
                                        </xforms:action>
                                </xforms:item>

                        </xforms:select1>

                        <xforms:case id="case-bar">
                                You chose "Bar"<br />
                        </xforms:case>
                        <xforms:case id="case-baz">
                                You chose "Baz"<br />
                        </xforms:case>

                </xforms:switch>

        </h:body>
</h:html>

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Evaluate instance data to detemine initial state of form

Mark Seaborne-3
Hi,

Well, you are best just to dump switch/case when you need something
like this.

Instead try:

            <xforms:group ref="/foo[. = 'bar']">
                You chose "Bar"<br />
            </xforms:group>
            <xforms:group ref="/foo[. = 'baz']">
                You chose "Baz"<br />
            </xforms:group>

In this way the view should reflect the state of the model. Each group
is only relevant when foo has a particular value, and I think the
default styling for non-relevance in the Firefox processor is display:
none.

Hope that helps

Mark


On Thu, 13 Sep 2007 07:59:15 -0700, CG wrote:

> I can't figure out how to toggle switch cases on load... I've been
> working on this example for several days and I can't seem to get that
> last detail to work. If I could evaluate an XPath expression in
> @selected in case, it'd be quite simple.
>
> Here's a simple example of a form missing that little incomplete
> facet... I want the form to output 'You chose "Baz"' as it's initial
> state. Thanks for your help!
>
>
> <h:html
>  xmlns:h="http://www.w3.org/1999/xhtml"
>  xmlns:xforms="http://www.w3.org/2002/xforms"
>  xmlns:ev="http://www.w3.org/2001/xml-events"
>>
> <h:head>
> <xforms:model>
> <xforms:instance xmlns="">
> <foo>baz</foo>
> </xforms:instance>
> </xforms:model>
> <h:title>Foo</h:title>
> </h:head>
>
> <h:body>
>
> <xforms:switch>
>
> <xforms:select1 ref="/foo">
> <xforms:label>Choose your metasyntactic varaible:</xforms:label>
> <xforms:item>
> <xforms:label>Bar</xforms:label>
> <xforms:value>bar</xforms:value>
> <xforms:action ev:event="xforms-select">
> <xforms:toggle case="case-bar" />
> </xforms:action>
> </xforms:item>
> <xforms:item>
> <xforms:label>Baz</xforms:label>
> <xforms:value>baz</xforms:value>
> <xforms:action ev:event="xforms-select">
> <xforms:toggle case="case-baz" />
> </xforms:action>
> </xforms:item>
>
> </xforms:select1>
>
> <xforms:case id="case-bar">
> You chose "Bar"<br />
> </xforms:case>
> <xforms:case id="case-baz">
> You chose "Baz"<br />
> </xforms:case>
>
> </xforms:switch>
>
> </h:body>
> </h:html>
>
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-xforms
Mark Seaborne
Senior Standards Architect
PicoForms
web:    http://www.picoforms.com
e-mail: [hidden email]
tel: +44 131 2080031
mobile:  +44 787 2180215

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Evaluate instance data to detemine initial state of form

Chris Gamache
In reply to this post by Chris Gamache
On Sep 13, 11:30 am, Mark Seaborne <[hidden email]> wrote:

Thank you for your response!

> Well, you are best just to dump switch/case when you need something
> like this.

Sounds good to me! I implemented the example and the initial view does
indeed reflect the state of the model now. However, Firefox does't
remove the irrelevant group from the display once it has been
displayed.

I'm trying not to use fine control for managing the presentation of
the XForms form, tho. I've tried revalidate, recalculate, refresh and
rebuild and none of those things seem to have the effect I am looking
for. I was hoping to not have to code for quirks, but it looks like I
may have to.

Am I overlooking an easy way to do what I need to do? What would you
suggest?

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Evaluate instance data to detemine initial state of form

Mark Seaborne-3
In reply to this post by Chris Gamache
> On Sep 13, 11:30 am, Mark Seaborne <[hidden email]> wrote:
>
> Thank you for your response!

That's okay.

>> Well, you are best just to dump switch/case when you need something
>> like this.
>
> Sounds good to me! I implemented the example and the initial view does
> indeed reflect the state of the model now. However, Firefox does't
> remove the irrelevant group from the display once it has been
> displayed.

Yes, I just tried it too, and I see what you mean.

Just to make sure, I tried the same form in a couple of other
processors, and they both behaved as expected - that is they hid the
disabled (non-relevant) group.

I wonder if this is a problem with the Firefox processor, rather than
your form?

I tried using explicit styling in CSS for :enabled and :disabled, and
the states don't seem to be updating properly.

> I'm trying not to use fine control for managing the presentation of
> the XForms form, tho. I've tried revalidate, recalculate, refresh and
> rebuild and none of those things seem to have the effect I am looking
> for. I was hoping to not have to code for quirks, but it looks like I
> may have to.
>
> Am I overlooking an easy way to do what I need to do? What would you
> suggest?

At the moment, try your form in another XForms processor ;-)

Unless, someone else can spot a bug in the form (which would be
preferable)?

All the best

Mark
 
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-xforms
Mark Seaborne
Senior Standards Architect
PicoForms
web:    http://www.picoforms.com
e-mail: [hidden email]
tel: +44 131 2080031
mobile:  +44 787 2180215

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Evaluate instance data to detemine initial state of form

Clark, John
> Yes, I just tried it too, and I see what you mean.

> I wonder if this is a problem with the Firefox processor, rather than
> your form?

This looks like a Mozilla XForms Extension bug to me, and an odd one at that, as I've been depending on the :disabled -hiding functionality for some time now... and successfully!  I don't really understand what's going on here.  Do you guys want to post the bug report, or should I?  :)

Take care,

    John L. Clark

===================================

Cleveland Clinic is ranked one of the top hospitals
in America by U.S. News & World Report (2007).  
Visit us online at http://www.clevelandclinic.org for
a complete listing of our services, staff and
locations.


Confidentiality Note:  This message is intended for use
only by the individual or entity to which it is addressed
and may contain information that is privileged,
confidential, and exempt from disclosure under applicable
law.  If the reader of this message is not the intended
recipient or the employee or agent responsible for
delivering the message to the intended recipient, you are
hereby notified that any dissemination, distribution or
copying of this communication is strictly prohibited.  If
you have received this communication in error,  please
contact the sender immediately and destroy the material in
its entirety, whether electronic or hard copy.  Thank you.


_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Evaluate instance data to detemine initial state of form

Mark Seaborne-3
On Thu, 13 Sep 2007 17:05:51 -0400, Clark, John wrote:

>> Yes, I just tried it too, and I see what you mean.
>
>> I wonder if this is a problem with the Firefox processor, rather than
>> your form?
>
> This looks like a Mozilla XForms Extension bug to me, and an odd one
> at that, as I've been depending on the :disabled -hiding
> functionality for some time now... and successfully!  I don't really
> understand what's going on here.  Do you guys want to post the bug
> report, or should I?  :)

Yes, I have used it successfully in the past too. Feel free to post the
bug, I'm off to bed ;-)

Good night.

Mark

>
> Take care,
>
>     John L. Clark
>
> ===================================
>
> Cleveland Clinic is ranked one of the top hospitals
> in America by U.S. News & World Report (2007).  
> Visit us online at http://www.clevelandclinic.org for
> a complete listing of our services, staff and
> locations.
>
>
> Confidentiality Note:  This message is intended for use
> only by the individual or entity to which it is addressed
> and may contain information that is privileged,
> confidential, and exempt from disclosure under applicable
> law.  If the reader of this message is not the intended
> recipient or the employee or agent responsible for
> delivering the message to the intended recipient, you are
> hereby notified that any dissemination, distribution or
> copying of this communication is strictly prohibited.  If
> you have received this communication in error,  please
> contact the sender immediately and destroy the material in
> its entirety, whether electronic or hard copy.  Thank you.
>
>
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]
> https://lists.mozilla.org/listinfo/dev-tech-xforms
Mark Seaborne
Senior Standards Architect
PicoForms
web:    http://www.picoforms.com
e-mail: [hidden email]
tel: +44 131 2080031
mobile:  +44 787 2180215

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Evaluate instance data to detemine initial state of form

Aaron Reed
In reply to this post by Chris Gamache

This approach works on Novell and Orbeon.  Not on formsPlayer or Sidewinder.

The way that our code works is that if we find that our bound node (in
this case foo = baz) has changed, we run the refresh logic.  Otherwise,
if a control does not have a bound node but it DOES depend on the
changed node (in this case foo = bar), then we rebind the control (which
will cause the control to refresh).  So you can see, if we already know
that a control will refresh, we don't rebind it.

All I can see in the spec on point is in 4.3.4 #1 (where it says to
reevaluate the UI bindings as necessary) and 4.6.7 #3.  I guess that we
violate 4.3.4 #1 since we aren't blindly re-evaluating the UI binding
expression if a dependent node changes.  I guess we were trying to be
too smart.

If you agree that this is a bug, please open a bug on us and attach a
testcase.  Might be worth adding this testcase to the xforms testsuite
to make sure that 4.3.4 #1 is getting enforced correctly.

--Aaron

Mark Seaborne wrote:

>> On Sep 13, 11:30 am, Mark Seaborne <[hidden email]> wrote:
>>
>> Thank you for your response!
>
> That's okay.
>
>>> Well, you are best just to dump switch/case when you need something
>>> like this.
>> Sounds good to me! I implemented the example and the initial view does
>> indeed reflect the state of the model now. However, Firefox does't
>> remove the irrelevant group from the display once it has been
>> displayed.
>
> Yes, I just tried it too, and I see what you mean.
>
> Just to make sure, I tried the same form in a couple of other
> processors, and they both behaved as expected - that is they hid the
> disabled (non-relevant) group.
>
> I wonder if this is a problem with the Firefox processor, rather than
> your form?
>
> I tried using explicit styling in CSS for :enabled and :disabled, and
> the states don't seem to be updating properly.
>
>> I'm trying not to use fine control for managing the presentation of
>> the XForms form, tho. I've tried revalidate, recalculate, refresh and
>> rebuild and none of those things seem to have the effect I am looking
>> for. I was hoping to not have to code for quirks, but it looks like I
>> may have to.
>>
>> Am I overlooking an easy way to do what I need to do? What would you
>> suggest?
>
> At the moment, try your form in another XForms processor ;-)
>
> Unless, someone else can spot a bug in the form (which would be
> preferable)?
>
> All the best
>
> Mark
>  
>> _______________________________________________
>> dev-tech-xforms mailing list
>> [hidden email]
>> https://lists.mozilla.org/listinfo/dev-tech-xforms
> Mark Seaborne
> Senior Standards Architect
> PicoForms
> web:    http://www.picoforms.com
> e-mail: [hidden email]
> tel: +44 131 2080031
> mobile:  +44 787 2180215
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms