xforms:upload updating two parts of the model

View: New views
10 Messages — Rating Filter:   Alert me  

xforms:upload updating two parts of the model

by Nuno Job :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm developing a XForms front-end to create a METS manifest.

  1. <mets>
  2.   <fileSec>
  3.     <fileGrp>
  4.       <file ID="" MIMETYPE="">
  5.         <FContent>
  6.           <binData xsi:type="xsd:base64Binary"/>
  7.         </FContent>
  8.       </file>
  9.     </fileGrp>
  10.   </fileSec>
  11.   <structMap>
  12.     <div TYPE="file:categories">
  13.       <div TYPE="file:categories:report">
  14.         <fptr FILEID=""/>
  15.       </div>
  16.     </div>
  17.   </structMap>
  18. </mets>
My problem is that when someone put the value in the xform:upload i need to update the three colored places. I'm ok with the green parts but the red part I simply have no clue how to do it. When you choose a file and the category of that file, the file should be stored in binData (achieved), the ID and MIMETYPE should be updated (achieved) and a new fptr with the FILEID should be created in the div of the specified category (this is what I don't have a clue on how to do).

  1.             <xforms:repeat id="files-repeat"
  2.                            nodeset="/mets/fileSec/fileGrp/file">
  3.               <xforms:group id="file-group" class="container">
  4.                 <xforms:output value="concat('Filename #', @ID)"/>
  5.                 <xforms:select1  ref="mets/structMap/div[@ID==id]/div" appearance="compact">
  6.                   <xforms:label>Section</xforms:label>
  7.                   <xforms:itemset model="sections-model"
  8.                                   nodeset="//section">
  9.                     <xforms:label ref="name"/>
  10.                     <xforms:value ref="id"/>
  11.                     <xforms:hint ref="description"/>
  12.                   </xforms:itemset>
  13.                 </xforms:select1>
  14.                 <xforms:upload ref="FContent/binData">
  15.                   <xforms:label>File</xforms:label>
  16.                   <xforms:filename ref="/mets/fileSec/fileGrp/file[index('files-repeat')]/@ID"/>
  17.                   <xforms:mediatype ref="/mets/fileSec/fileGrp/file[index('files-repeat')]/@MIMETYPE"/>
  18.                 </xforms:upload>
Is this possible? How? I thought of using actions but how can I be sure the form is synchronized with the model if I go that way?

Thanks so much for the help,

Nuno

Re: xforms:upload updating two parts of the model

by Mark Birbeck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Nuno,

Can I just clarify the question? Is the problem as simple as needing
to duplicate the value from filegrp/file/@ID to fptr/@FILEID? Or is it
slightly more complex in that the fptr element must also be created?

Regards,

Mark

--
  Mark Birbeck

  mark.birbeck@... | +44 (0) 20 7689 9232
  http://www.x-port.net | http://internet-apps.blogspot.com

  x-port.net Ltd. is registered in England and Wales, number 03730711
  The registered office is at:

    2nd Floor
    Titchfield House
    69-85 Tabernacle Street
    London
    EC2A 4RR



On 23/02/2008, Nuno Job <nunojobpinto@...> wrote:

> I'm developing a XForms front-end to create a METS manifest.
>
> >
> >
> > <mets>
> >   <fileSec>
> >     <fileGrp>
> >       <file ID="" MIMETYPE="">
> >         <FContent>
> >           <binData xsi:type="xsd:base64Binary"/>
> >         </FContent>
> >       </file>
> >     </fileGrp>
> >   </fileSec>
> >   <structMap>
> >     <div TYPE="file:categories">
> >       <div TYPE="file:categories:report">
> >         <fptr FILEID=""/>
> >       </div>
> >     </div>
> >   </structMap>
> > </mets>
> My problem is that when someone put the value in the xform:upload i need to
> update the three colored places. I'm ok with the green parts but the red
> part I simply have no clue how to do it. When you choose a file and the
> category of that file, the file should be stored in binData (achieved), the
> ID and MIMETYPE should be updated (achieved) and a new fptr with the FILEID
> should be created in the div of the specified category (this is what I don't
> have a clue on how to do).
>
> >
> >
> >             <xforms:repeat id="files-repeat"
> >
> nodeset="/mets/fileSec/fileGrp/file">
> >               <xforms:group id="file-group" class="container">
> >                 <xforms:output value="concat('Filename #', @ID)"/>
> >                 <xforms:select1
> ref="mets/structMap/div[@ID==id]/div" appearance="compact">
> >                   <xforms:label>Section</xforms:label>
> >                   <xforms:itemset model="sections-model"
> >                                   nodeset="//section">
> >                     <xforms:label ref="name"/>
> >                     <xforms:value ref="id"/>
> >                     <xforms:hint ref="description"/>
> >                   </xforms:itemset>
> >                 </xforms:select1>
> >                 <xforms:upload ref="FContent/binData">
> >                   <xforms:label>File</xforms:label>
> >                   <xforms:filename
> ref="/mets/fileSec/fileGrp/file[index('files-repeat')]/@ID"/>
> >                   <xforms:mediatype
> ref="/mets/fileSec/fileGrp/file[index('files-repeat')]/@MIMETYPE"/>
> >                 </xforms:upload>
> Is this possible? How? I thought of using actions but how can I be sure the
> form is synchronized with the model if I go that way?
>
> Thanks so much for the help,
>
> Nuno
>


Re: xforms:upload updating two parts of the model

by Nuno Job :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,


Hi Nuno,

Can I just clarify the question? Is the problem as simple as needing
to duplicate the value from filegrp/file/@ID to fptr/@FILEID? Or is it
slightly more complex in that the fptr element must also be created?

It's the more complex  solution. Do you know how to do it?

Anyway I'm ging to release a screencast on xforms and ruby on rails - TODAY - at my blog. Your welcome to check it out. I'll message the list when it's up on nunojob.wordpress.com.

Footnote: That is not implemented :P I didn't know how to and had very limited time to present the screencast.

Regards,

Mark

Thanks for the help,

Regards,
Nuno


Re: xforms:upload updating two parts of the model

by Mark Birbeck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Nuno,

Have you tried hooking an xf:insert action handler onto the
xforms-value-changed event? Unfortunately, one of the quirks about
XForms 1.x is that you can only hook the XVC event in a UI control, so
it will 'feel' wrong to do this. But anyway, putting that aside,
register for the change on the file id, and when you get it, test for
the existence of the element, and if it doesn't exist create it from a
template. Then copy in the file id.

Regards,

Mark

On 25/02/2008, Nuno Job <nunojobpinto@...> wrote:

> Hi,
>
>
>
> > Hi Nuno,
> >
> > Can I just clarify the question? Is the problem as simple as needing
> > to duplicate the value from filegrp/file/@ID to fptr/@FILEID? Or is it
> > slightly more complex in that the fptr element must also be created?
>
> It's the more complex  solution. Do you know how to do it?
>
> Anyway I'm ging to release a screencast on xforms and ruby on rails - TODAY
> - at my blog. Your welcome to check it out. I'll message the list when it's
> up on nunojob.wordpress.com.
>
> Footnote: That is not implemented :P I didn't know how to and had very
> limited time to present the screencast.
>
> > Regards,
> >
> > Mark
>
> Thanks for the help,
>
> Regards,
> Nuno
>
>


--
  Mark Birbeck

  mark.birbeck@... | +44 (0) 20 7689 9232
  http://www.x-port.net | http://internet-apps.blogspot.com

  x-port.net Ltd. is registered in England and Wales, number 03730711
  The registered office is at:

    2nd Floor
    Titchfield House
    69-85 Tabernacle Street
    London
    EC2A 4RR


Re: xforms:upload updating two parts of the model

by John Boyer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Mark,

Not sure, but I think you may have suggested that an xforms-value-changed (XVC) will happen on the filename child element of an upload.
Just in case that's what you meant, the current spec does not support that because the ref used in filename is not a UI binding.  Only full-blown form controls receive events from the model corresponding to their UI bindings.

It may work in an implementation that treats every ref as a UI binding, but then you have odd stuff happening like XVC events going to setvalue and such.

John M. Boyer, Ph.D.
Senior Technical Staff Member
Lotus Forms Architect and Researcher
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@...  

Blog:
http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed:
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw




"Mark Birbeck" <mark.birbeck@...>
Sent by: www-forms-request@...

02/25/2008 03:39 PM

To
"Nuno Job" <nunojobpinto@...>
cc
www-forms@...
Subject
Re: xforms:upload updating two parts of the model






Hi Nuno,

Have you tried hooking an xf:insert action handler onto the
xforms-value-changed event? Unfortunately, one of the quirks about
XForms 1.x is that you can only hook the XVC event in a UI control, so
it will 'feel' wrong to do this. But anyway, putting that aside,
register for the change on the file id, and when you get it, test for
the existence of the element, and if it doesn't exist create it from a
template. Then copy in the file id.

Regards,

Mark

On 25/02/2008, Nuno Job <nunojobpinto@...> wrote:
> Hi,
>
>
>
> > Hi Nuno,
> >
> > Can I just clarify the question? Is the problem as simple as needing
> > to duplicate the value from filegrp/file/@ID to fptr/@FILEID? Or is it
> > slightly more complex in that the fptr element must also be created?
>
> It's the more complex  solution. Do you know how to do it?
>
> Anyway I'm ging to release a screencast on xforms and ruby on rails - TODAY
> - at my blog. Your welcome to check it out. I'll message the list when it's
> up on nunojob.wordpress.com.
>
> Footnote: That is not implemented :P I didn't know how to and had very
> limited time to present the screencast.
>
> > Regards,
> >
> > Mark
>
> Thanks for the help,
>
> Regards,
> Nuno
>
>


--
 Mark Birbeck

 mark.birbeck@... | +44 (0) 20 7689 9232
 
http://www.x-port.net | http://internet-apps.blogspot.com

 x-port.net Ltd. is registered in England and Wales, number 03730711
 The registered office is at:

   2nd Floor
   Titchfield House
   69-85 Tabernacle Street
   London
   EC2A 4RR



Re: xforms:upload updating two parts of the model

by Nuno Job :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

With all of this I'm uncertain about the right way of implementing this. Soon I will begin the next phase of development and therefor I would really appreciate if someone could give me some pointers in the right directions. For that I thank you both.

I have published an blog post on what I'm doing so if your interested in the XForms code you can check it our here

Thanks for all the help,

Kind regards,
Nuno Job
IBM DB2 Student Ambassador [ http://caos.di.uminho.pt/~db2 ]
Open Source Support Center Member [http://caos.di.uminho.pt ]
Blog [ http://nunojob.wordpress.com ] LinkedIn [ http://www.linkedin.com/in/njpinto ]

On Tue, Feb 26, 2008 at 2:17 AM, John Boyer <boyerj@...> wrote:

Hi Mark,

Not sure, but I think you may have suggested that an xforms-value-changed (XVC) will happen on the filename child element of an upload.
Just in case that's what you meant, the current spec does not support that because the ref used in filename is not a UI binding.  Only full-blown form controls receive events from the model corresponding to their UI bindings.

It may work in an implementation that treats every ref as a UI binding, but then you have odd stuff happening like XVC events going to setvalue and such.

John M. Boyer, Ph.D.
Senior Technical Staff Member
Lotus Forms Architect and Researcher
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@...  

Blog:
http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed:
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw




"Mark Birbeck" <mark.birbeck@...>
Sent by: www-forms-request@...

02/25/2008 03:39 PM

To
"Nuno Job" <nunojobpinto@...>
cc
www-forms@...
Subject
Re: xforms:upload updating two parts of the model






Hi Nuno,

Have you tried hooking an xf:insert action handler onto the
xforms-value-changed event? Unfortunately, one of the quirks about
XForms 1.x is that you can only hook the XVC event in a UI control, so
it will 'feel' wrong to do this. But anyway, putting that aside,
register for the change on the file id, and when you get it, test for
the existence of the element, and if it doesn't exist create it from a
template. Then copy in the file id.

Regards,

Mark

On 25/02/2008, Nuno Job <nunojobpinto@...> wrote:
> Hi,
>
>
>
> > Hi Nuno,
> >
> > Can I just clarify the question? Is the problem as simple as needing
> > to duplicate the value from filegrp/file/@ID to fptr/@FILEID? Or is it
> > slightly more complex in that the fptr element must also be created?
>
> It's the more complex  solution. Do you know how to do it?
>
> Anyway I'm ging to release a screencast on xforms and ruby on rails - TODAY
> - at my blog. Your welcome to check it out. I'll message the list when it's
> up on nunojob.wordpress.com.
>
> Footnote: That is not implemented :P I didn't know how to and had very
> limited time to present the screencast.
>
> > Regards,
> >
> > Mark
>
> Thanks for the help,
>
> Regards,
> Nuno
>
>


--
 Mark Birbeck

 mark.birbeck@... | +44 (0) 20 7689 9232
 
http://www.x-port.net | http://internet-apps.blogspot.com

 x-port.net Ltd. is registered in England and Wales, number 03730711
 The registered office is at:

   2nd Floor
   Titchfield House
   69-85 Tabernacle Street
   London
   EC2A 4RR


Re: xforms:upload updating two parts of the model

by Mark Birbeck :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi John,

> Not sure, but I think you may have suggested that an xforms-value-changed
> (XVC) will happen on the filename child element of an upload.
> Just in case that's what you meant, the current spec does not support that
> because the ref used in filename is not a UI binding.  Only full-blown form
> controls receive events from the model corresponding to their UI bindings.
>
> It may work in an implementation that treats every ref as a UI binding, but
> then you have odd stuff happening like XVC events going to setvalue and such.

No...I'm definitely *not* saying that XVC applies to anything other
than a form control.

And that's exactly the problem!

It means that for authors to register a handler that will perform some
action whenever a particular node has changed, they have to create a
redundant form control:

  <style>
    .xvc-event-handler { display: none; }
  </style>

  <xf:output ref="node-to-watch" class="xvc-event-handler">
    <xf:action ev:event="xforms-value-changed">
      ...
    </xf;action>
  </xf;output>

Best regards,

Mark

--
  Mark Birbeck

  mark.birbeck@... | +44 (0) 20 7689 9232
  http://www.x-port.net | http://internet-apps.blogspot.com

  x-port.net Ltd. is registered in England and Wales, number 03730711
  The registered office is at:

    2nd Floor
    Titchfield House
    69-85 Tabernacle Street
    London
    EC2A 4RR


Re: xforms:upload updating two parts of the model

by Erik Bruchez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Couldn't one register a listener for DOM Mutation Events? Does any  
XForms implementation do this?

-Erik

On Feb 26, 2008, at 3:43 AM, Mark Birbeck wrote:

>
> Hi John,
>
>> Not sure, but I think you may have suggested that an xforms-value-
>> changed
>> (XVC) will happen on the filename child element of an upload.
>> Just in case that's what you meant, the current spec does not  
>> support that
>> because the ref used in filename is not a UI binding.  Only full-
>> blown form
>> controls receive events from the model corresponding to their UI  
>> bindings.
>>
>> It may work in an implementation that treats every ref as a UI  
>> binding, but
>> then you have odd stuff happening like XVC events going to setvalue  
>> and such.
>
> No...I'm definitely *not* saying that XVC applies to anything other
> than a form control.
>
> And that's exactly the problem!
>
> It means that for authors to register a handler that will perform some
> action whenever a particular node has changed, they have to create a
> redundant form control:
>
>  <style>
>    .xvc-event-handler { display: none; }
>  </style>
>
>  <xf:output ref="node-to-watch" class="xvc-event-handler">
>    <xf:action ev:event="xforms-value-changed">
>      ...
>    </xf;action>
>  </xf;output>
>
> Best regards,
>
> Mark
>
> --
>  Mark Birbeck
>
>  mark.birbeck@... | +44 (0) 20 7689 9232
>  http://www.x-port.net | http://internet-apps.blogspot.com
>
>  x-port.net Ltd. is registered in England and Wales, number 03730711
>  The registered office is at:
>
>    2nd Floor
>    Titchfield House
>    69-85 Tabernacle Street
>    London
>    EC2A 4RR
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/



Re: xforms:upload updating two parts of the model

by John Boyer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Erik,

I don't think so, unfortunately.

The instances are *separate* running DOMs from the main document where event listeners would be expressed, and their is no way with XML events to indicate that you would like to listen for something to happen in another document.

Actually, you should send that along as an XML Events 2 suggestion to www-html-editor

Cheers,
John M. Boyer, Ph.D.
Senior Technical Staff Member
Lotus Forms Architect and Researcher
Chair, W3C Forms Working Group
Workplace, Portal and Collaboration Software
IBM Victoria Software Lab
E-Mail: boyerj@...  

Blog:
http://www.ibm.com/developerworks/blogs/page/JohnBoyer
Blog RSS feed:
http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw




Erik Bruchez <ebruchez@...>
Sent by: www-forms-request@...

02/26/2008 05:29 PM

To
www-forms@...
cc
Subject
Re: xforms:upload updating two parts of the model






Couldn't one register a listener for DOM Mutation Events? Does any  
XForms implementation do this?

-Erik

On Feb 26, 2008, at 3:43 AM, Mark Birbeck wrote:

>
> Hi John,
>
>> Not sure, but I think you may have suggested that an xforms-value-
>> changed
>> (XVC) will happen on the filename child element of an upload.
>> Just in case that's what you meant, the current spec does not  
>> support that
>> because the ref used in filename is not a UI binding.  Only full-
>> blown form
>> controls receive events from the model corresponding to their UI  
>> bindings.
>>
>> It may work in an implementation that treats every ref as a UI  
>> binding, but
>> then you have odd stuff happening like XVC events going to setvalue  
>> and such.
>
> No...I'm definitely *not* saying that XVC applies to anything other
> than a form control.
>
> And that's exactly the problem!
>
> It means that for authors to register a handler that will perform some
> action whenever a particular node has changed, they have to create a
> redundant form control:
>
>  <style>
>    .xvc-event-handler { display: none; }
>  </style>
>
>  <xf:output ref="node-to-watch" class="xvc-event-handler">
>    <xf:action ev:event="xforms-value-changed">
>      ...
>    </xf;action>
>  </xf;output>
>
> Best regards,
>
> Mark
>
> --
>  Mark Birbeck
>
>  mark.birbeck@... | +44 (0) 20 7689 9232
>  
http://www.x-port.net | http://internet-apps.blogspot.com
>
>  x-port.net Ltd. is registered in England and Wales, number 03730711
>  The registered office is at:
>
>    2nd Floor
>    Titchfield House
>    69-85 Tabernacle Street
>    London
>    EC2A 4RR
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/




Re: xforms:upload updating two parts of the model

by Erik Bruchez :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Done.

http://www.nabble.com/Suggestion-for-XML-Events-2%3A-listening-to-events-in-a-separate-document-td16488849.html

-Erik

On Feb 26, 2008, at 5:11 PM, John Boyer wrote:

>
> Hi Erik,
>
> I don't think so, unfortunately.
>
> The instances are *separate* running DOMs from the main document  
> where event listeners would be expressed, and their is no way with  
> XML events to indicate that you would like to listen for something  
> to happen in another document.
>
> Actually, you should send that along as an XML Events 2 suggestion  
> to www-html-editor
>
> Cheers,
> John M. Boyer, Ph.D.
> Senior Technical Staff Member
> Lotus Forms Architect and Researcher
> Chair, W3C Forms Working Group
> Workplace, Portal and Collaboration Software
> IBM Victoria Software Lab
> E-Mail: boyerj@...
>
> Blog: http://www.ibm.com/developerworks/blogs/page/JohnBoyer
> Blog RSS feed: http://www.ibm.com/developerworks/blogs/rss/JohnBoyer?flavor=rssdw
>
>
>
>
> Erik Bruchez <ebruchez@...>
> Sent by: www-forms-request@...
> 02/26/2008 05:29 PM
>
> To
> www-forms@...
> cc
> Subject
> Re: xforms:upload updating two parts of the model
>
>
>
>
>
>
> Couldn't one register a listener for DOM Mutation Events? Does any
> XForms implementation do this?
>
> -Erik
>
> On Feb 26, 2008, at 3:43 AM, Mark Birbeck wrote:
>
> >
> > Hi John,
> >
> >> Not sure, but I think you may have suggested that an xforms-value-
> >> changed
> >> (XVC) will happen on the filename child element of an upload.
> >> Just in case that's what you meant, the current spec does not
> >> support that
> >> because the ref used in filename is not a UI binding.  Only full-
> >> blown form
> >> controls receive events from the model corresponding to their UI
> >> bindings.
> >>
> >> It may work in an implementation that treats every ref as a UI
> >> binding, but
> >> then you have odd stuff happening like XVC events going to setvalue
> >> and such.
> >
> > No...I'm definitely *not* saying that XVC applies to anything other
> > than a form control.
> >
> > And that's exactly the problem!
> >
> > It means that for authors to register a handler that will perform  
> some
> > action whenever a particular node has changed, they have to create a
> > redundant form control:
> >
> >  <style>
> >    .xvc-event-handler { display: none; }
> >  </style>
> >
> >  <xf:output ref="node-to-watch" class="xvc-event-handler">
> >    <xf:action ev:event="xforms-value-changed">
> >      ...
> >    </xf;action>
> >  </xf;output>
> >
> > Best regards,
> >
> > Mark
> >
> > --
> >  Mark Birbeck
> >
> >  mark.birbeck@... | +44 (0) 20 7689 9232
> >  http://www.x-port.net | http://internet-apps.blogspot.com
> >
> >  x-port.net Ltd. is registered in England and Wales, number 03730711
> >  The registered office is at:
> >
> >    2nd Floor
> >    Titchfield House
> >    69-85 Tabernacle Street
> >    London
> >    EC2A 4RR
> >
>
> --
> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> http://www.orbeon.com/
>
>
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
http://www.orbeon.com/


LightInTheBox - Buy quality products at wholesale price!