Toggling attribute(s) with a checkbox

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

Toggling attribute(s) with a checkbox

mbklein-2
I'm trying to figure out an elegant way to implement something fairly
simple. I'm working with MODS data, and the instance document can contain
one or more <mods:typeOfResource/> elements. Each one has a text value
(selected from a drop-down) and up to two optional elements, 'manuscript'
and 'collection'. So, for example:

<mods:typeOfResource collection="yes">text</mods:typeOfResource>

I want there to be two checkboxes next to the drop down, indicating the
existence/value of the two optional attributes. Ideally, I'd like the value
set to "yes" if the checkbox is checked, and the attribute deleted entirely
if the checkbox is unchecked.

Given the way checkboxes are used in XForms, as a <select> style, is there a
good way to accomplish this without relying on pre- and post-processing?

Thanks,
Michael

--
Michael B. Klein
Digital Initiatives Technology Librarian
Boston Public Library
(617) 859-2391
[hidden email]



--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Toggling attribute(s) with a checkbox

Hank Ratzesberger
Hi Michael,


On Sep 3, 2008, at 7:07 AM, Klein, Michael wrote:

> I'm trying to figure out an elegant way to implement something fairly
> simple. I'm working with MODS data, and the instance document can  
> contain
> one or more <mods:typeOfResource/> elements. Each one has a text value
> (selected from a drop-down) and up to two optional elements,  
> 'manuscript'
> and 'collection'. So, for example:
>
> <mods:typeOfResource collection="yes">text</mods:typeOfResource>
>
> I want there to be two checkboxes next to the drop down, indicating  
> the
> existence/value of the two optional attributes. Ideally, I'd like  
> the value
> set to "yes" if the checkbox is checked, and the attribute deleted  
> entirely
> if the checkbox is unchecked.
>
It is not clear to me what the two checkboxes do, but If you want to
filter the drop down list items based on a checkbox value, you can
do that if you add a setvalue element to the checkbox that updates an
instance.  The updated instance can be referred to in the xpath that
selects the drop down.

e.g., the drop down items nodeset contains an xpath statement that
depends on a separate instance to filter:

<xforms:itemset nodeset="instance('mods')//typeofResource[matches
(.,instance('mod-filter')/filter-text)]">
   <xforms:label><xforms:output value="?????"/></xforms:label>
   <xforms:value ref="?????"/>
</xforms:itemset>


and the check box has

<xforms:event ev:event="xforms-value-changed">
        <xforms:setvalue ref="instance('mod-filter')/filter" value="new-
value"/>
</xforms:event>

I'm 99% certain the xforms engine will understand this dependency and  
redraw
the dropdown list.

Let us know how it goes,
Hank



> Given the way checkboxes are used in XForms, as a <select> style,  
> is there a
> good way to accomplish this without relying on pre- and post-
> processing?
>
> Thanks,
> Michael
>
> --
> Michael B. Klein
> Digital Initiatives Technology Librarian
> Boston Public Library
> (617) 859-2391
> [hidden email]
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws
Hank Ratzesberger
NEES@UCSB
Institute for Crustal Studies,
University of California, Santa Barbara
805-893-8042







--
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
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: Toggling attribute(s) with a checkbox

mbklein-2
Sorry for the confusion -- the checkboxes are not designed to filter the
list. I simply want them to toggle certain attributes on and off.

So if I have:

In the following example, the manuscript and collection boxes should both
appear, but remain unchecked:

<mods:typeOfResource>text</mods:typeOfResource>

In this example, the manuscript box is checked, and the collection box is
unchecked:

<mods:typeOfResource manuscript="yes">text</mods:typeOfResource>

I managed to figured out a workaround that adds an additional attribute (in
a different namespace) to the element. Some examples:

<mods:typeOfResource local:flags="">text</mods:typeOfResource>

<mods:typeOfResource manuscript="yes"
  local:flags="manuscript">text</mods:typeOfResource>

<mods:typeOfResource manuscript="yes" collection="yes"
  local:flags="collection manuscript">text</mods:typeOfResource>

@local:flags is initialized using an iterator in
xforms-model-construct-done, and whenever a new mods:typeOfResource element
is added. The <xforms:select> then operates on @local:flags, with an
xforms-value-changed handler that <insert>s, <delete>s, or <setvalue>s
@manuscript and @collection based on the new value of @local:flags. I also
have an xforms-submit handler that prevents @local:flags from being
serialized.

So there's still some pre- and post-processing involved, but it's entirely
contained within the form and doesn't affect the receiving application at
all.

--
Michael B. Klein
Digital Initiatives Technology Librarian
Boston Public Library
(617) 859-2391
[hidden email]


> From: Hank Ratzesberger <[hidden email]>
> Reply-To: <[hidden email]>
> Date: Wed, 3 Sep 2008 11:50:15 -0700
> To: <[hidden email]>
> Subject: [ops-users] Re: Toggling attribute(s) with a checkbox
>
> Hi Michael,
>
>
> On Sep 3, 2008, at 7:07 AM, Klein, Michael wrote:
>
>> I'm trying to figure out an elegant way to implement something fairly
>> simple. I'm working with MODS data, and the instance document can
>> contain
>> one or more <mods:typeOfResource/> elements. Each one has a text value
>> (selected from a drop-down) and up to two optional elements,
>> 'manuscript'
>> and 'collection'. So, for example:
>>
>> <mods:typeOfResource collection="yes">text</mods:typeOfResource>
>>
>> I want there to be two checkboxes next to the drop down, indicating
>> the
>> existence/value of the two optional attributes. Ideally, I'd like
>> the value
>> set to "yes" if the checkbox is checked, and the attribute deleted
>> entirely
>> if the checkbox is unchecked.
>>
>
> It is not clear to me what the two checkboxes do, but If you want to
> filter the drop down list items based on a checkbox value, you can
> do that if you add a setvalue element to the checkbox that updates an
> instance.  The updated instance can be referred to in the xpath that
> selects the drop down.
>
> e.g., the drop down items nodeset contains an xpath statement that
> depends on a separate instance to filter:
>
> <xforms:itemset nodeset="instance('mods')//typeofResource[matches
> (.,instance('mod-filter')/filter-text)]">
>    <xforms:label><xforms:output value="?????"/></xforms:label>
>    <xforms:value ref="?????"/>
> </xforms:itemset>
>
>
> and the check box has
>
> <xforms:event ev:event="xforms-value-changed">
> <xforms:setvalue ref="instance('mod-filter')/filter" value="new-
> value"/>
> </xforms:event>
>
> I'm 99% certain the xforms engine will understand this dependency and
> redraw
> the dropdown list.
>
> Let us know how it goes,
> Hank
>
>
>
>> Given the way checkboxes are used in XForms, as a <select> style,
>> is there a
>> good way to accomplish this without relying on pre- and post-
>> processing?
>>
>> Thanks,
>> Michael
>>
>> --
>> Michael B. Klein
>> Digital Initiatives Technology Librarian
>> Boston Public Library
>> (617) 859-2391
>> [hidden email]
>>
>>
>> --
>> 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
>> OW2 mailing lists service home page: http://www.ow2.org/wws
>
> Hank Ratzesberger
> NEES@UCSB
> Institute for Crustal Studies,
> University of California, Santa Barbara
> 805-893-8042
>
>
>
>
>
>
> --
> 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
> OW2 mailing lists service home page: http://www.ow2.org/wws


--
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
OW2 mailing lists service home page: http://www.ow2.org/wws