RE: display input if its ref don't exist

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

RE: display input if its ref don't exist

aa aa-2
Hello!
 
I've back to work with this "problem" but I can found a good solution.
 
We have a big xml with a lot of possible missing fields. So pre-process that xml is very hard.
 
And we have a lot of input field (but we don't know when this input has to be bound to a node). And we can't add a but in each input, because is not very clear.
 
Do you know if it's possible another solution?? Perhaps add all this missing fields in a xforms-ready event o in a onchange event o...
 
That's very important for us. Thank you very much in advance.

> Date: Fri, 29 Jun 2007 12:04:01 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [ops-users] display input if its ref don't exist
>
> In XForms, a control that captures data has to be bound to a node,
> otherwise it is considered non-relevant, i.e. not accessible to the user
> (in this case it is usually invisible, or grayed out).
>
> If you want, XML data nodes are like variables holding control values.
> This is a fundamental aspect of XForms and it's hard to change it.
>
> I think you have a few options:
>
> * Do what you suggested, i.e. pre-process your XML document to add the
> missing fields.
>
> * Use an "Add phone number" button which uses xforms:insert to add the
> telephone2 field.
>
> -Erik
>
> aa aa wrote:
> > Thank you very much, now I undestand the problem.
> >
> > Of course I would like to stored the data. But sometimes we receive a
> > xml without any node. Por example:
> >
> > This is a complete xml:
> >
> > <document>
> > <telephone1>12345</telephone1>
> > <telephone2>54321</telephone2>
> > </document>
> >
> > An this one is a case when the person only have one telephone:
> >
> > <document>
> > <telephone1>12345</telephone1>
> > </document>
> >
> > But in the form we always want to display both inputs. What we can do
> > when we receive the second xml?? We have to preprocess the xml and add
> > "<telephone2/>"? This is very complecated in a big xml with a lot of
> > nodes...
> >
> > Thank you in advance!
> >
> > > Date: Thu, 28 Jun 2007 16:21:27 -0700
> > > From: [hidden email]
> > > To: [hidden email]
> > > Subject: Re: [ops-users] display input if its ref don't exist
> > >
> > > On 6/27/07, aa aa <[hidden email]> wrote:
> > > > I want to can click in it and enter data.
> > > >
> > > > Sometimes we have a incomplete xml, but we want to see all the inputs.
> > >
> > > But what happens if you enter data? It won't have anywhere to go,
> > > since there is no node to which the input is bound and where the data
> > > could be stored. Is this what you want?
> > >
> > > Alex
> > > --
> > > Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
> > > http://www.orbeon.com/
> > >
> >
> >
> > ------------------------------------------------------------------------
> > Busca desde cualquier página Web con una protección excepcional.
> > Consigue la Barra de herramientas de Windows Live hoy mismo
> > GRATUITAMENTE. Pruébalo <http://www.toolbar.live.com>
> >
>
>
> --
> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> http://www.orbeon.com/
>



Prueba algunos de los nuevos servicios en línea que te ofrece Windows Live Ideas: tan nuevos que ni siquiera se han publicado oficialmente todavía. Pruébalo

--
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: display input if its ref don't exist

aa aa-2
Hello again,
 
Finally we found two solution:
 
a) He can have another instance with a complete black document. And at the xforms-ready event do the next:
 

<xforms:insert nodeset="ConExplot" context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos" at="last()" position="after" origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/ConExplot"/>

<xforms:insert nodeset="GasPersonal" context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos" at="last()" position="after" origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/GasPersonal"/>

<xforms:insert nodeset="SueSalarios" context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos/GasPersonal" at="last()" position="after" origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/GasPersonal/SueSalarios"/>

...


with all the xml nodes. It's not a bad solution for a small xml.
 
b) Preprocess the xml comparing with a complete black document. That's the code:
 

/**

* Revisa el documento añadiendo los nodos que le falten

* @param documento

* @throws IOException

*/

public void revisarNodos(Element document, String formName) throws IOException {

InputStream is = getClass().getResourceAsStream("plantilla_"+formName+".xml");

Document plantilla = null;

try {

plantilla = Dom4jUtils.readDom4j(is);

} catch (SAXException e) {

throw new IOException(e.getMessage());

} catch (DocumentException e) {

throw new IOException(e.getMessage());

}

//Recorremos y comparamos ambos documentos

Element raizPlantilla = plantilla.getRootElement();

//Revisamos los hijos de forma recursiva

revisarHijos(raizPlantilla, document);

 

}

/**

* Revisa los hijos de dos elementos e inserta los nodos que le falten al segundo sobre el primero

* @param elementoPlantilla

* @param elementoDocumento

*/

private void revisarHijos(Element elementoPlantilla, Element elementoDocumento) {

int posicion = 0;

Iterator it = elementoPlantilla.elementIterator();

while ( it.hasNext() ) {

Element hijoPlantilla = (Element) it.next();

//Buscamos ese elemento en el documento

Element hijoDocumento = (Element) elementoDocumento.selectSingleNode(hijoPlantilla.getName());

//Si el elemento no existe lo añadimos, si existe lo revisamos

if (hijoDocumento == null) {

elementoDocumento.content().add(posicion, hijoPlantilla);

}

else {

revisarHijos(hijoPlantilla, hijoDocumento);

}

posicion++;

}

}
 
I hope this can help somebody.
 
Thank you and regards

From: [hidden email]
To: [hidden email]
Date: Thu, 12 Jul 2007 15:34:16 +0100
Subject: RE: [ops-users] display input if its ref don't exist

Hello!
 
I've back to work with this "problem" but I can found a good solution.
 
We have a big xml with a lot of possible missing fields. So pre-process that xml is very hard.
 
And we have a lot of input field (but we don't know when this input has to be bound to a node). And we can't add a but in each input, because is not very clear.
 
Do you know if it's possible another solution?? Perhaps add all this missing fields in a xforms-ready event o in a onchange event o...
 
That's very important for us. Thank you very much in advance.

> Date: Fri, 29 Jun 2007 12:04:01 +0200
> From: [hidden email]
> To: [hidden email]
> Subject: Re: [ops-users] display input if its ref don't exist
>
> In XForms, a control that captures data has to be bound to a node,
> otherwise it is considered non-relevant, i.e. not accessible to the user
> (in this case it is usually invisible, or grayed out).
>
> If you want, XML data nodes are like variables holding control values.
> This is a fundamental aspect of XForms and it's hard to change it.
>
> I think you have a few options:
>
> * Do what you suggested, i.e. pre-process your XML document to add the
> missing fields.
>
> * Use an "Add phone number" button which uses xforms:insert to add the
> telephone2 field.
>
> -Erik
>
> aa aa wrote:
> > Thank you very much, now I undestand the problem.
> >
> > Of course I would like to stored the data. But sometimes we receive a
> > xml without any node. Por example:
> >
> > This is a complete xml:
> >
> > <document>
> > <telephone1>12345</telephone1>
> > <telephone2>54321</telephone2>
> > </document>
> >
> > An this one is a case when the person only have one telephone:
> >
> > <document>
> > <telephone1>12345</telephone1>
> > </document>
> >
> > But in the form we always want to display both inputs. What we can do
> > when we receive the second xml?? We have to preprocess the xml and add
> > "<telephone2/>"? This is very complecated in a big xml with a lot of
> > nodes...
> >
> > Thank you in advance!
> >
> > > Date: Thu, 28 Jun 2007 16:21:27 -0700
> > > From: [hidden email]
> > > To: [hidden email]
> > > Subject: Re: [ops-users] display input if its ref don't exist
> > >
> > > On 6/27/07, aa aa <[hidden email]> wrote:
> > > > I want to can click in it and enter data.
> > > >
> > > > Sometimes we have a incomplete xml, but we want to see all the inputs.
> > >
> > > But what happens if you enter data? It won't have anywhere to go,
> > > since there is no node to which the input is bound and where the data
> > > could be stored. Is this what you want?
> > >
> > > Alex
> > > --
> > > Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
> > > http://www.orbeon.com/
> > >
> >
> >
> > ------------------------------------------------------------------------
> > Busca desde cualquier página Web con una protección excepcional.
> > Consigue la Barra de herramientas de Windows Live hoy mismo
> > GRATUITAMENTE. Pruébalo <http://www.toolbar.live.com>
> >
>
>
> --
> Orbeon Forms - Web Forms for the Enterprise Done the Right Way
> http://www.orbeon.com/
>



Prueba algunos de los nuevos servicios en línea que te ofrece Windows Live Ideas: tan nuevos que ni siquiera se han publicado oficialmente todavía. Pruébalo


Llama a tus amigos de PC a PC: ¡Es GRATIS! Pruébalo

--
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: display input if its ref don't exist

Erik Bruchez
Administrator
Thanks for letting all of us know. We are glad you found a solution!

Best,

-Erik

aa aa wrote:

> Hello again,
>  
> Finally we found two solution:
>  
> a) He can have another instance with a complete black document. And at
> the xforms-ready event do the next:
>  
>
> <xforms:insert nodeset="ConExplot"
> context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos"
> at="last()" position="after"
> origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/ConExplot"/>
>
> <xforms:insert nodeset="GasPersonal"
> context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos"
> at="last()" position="after"
> origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/GasPersonal"/>
>
> <xforms:insert nodeset="SueSalarios"
> context="instance('documento-instance')/SocMercantil_EPE/PYG/Gastos/GasPersonal"
> at="last()" position="after"
> origin="instance('documento-template')/SocMercantil_EPE/PYG/Gastos/GasPersonal/SueSalarios"/>
>
> ...
>
> with all the xml nodes. It's not a bad solution for a small xml.
>  
> b) Preprocess the xml comparing with a complete black document. That's
> the code:
>  
>
> /**
>
> * Revisa el documento añadiendo los nodos que le falten
>
> * *@param* documento
>
> * *@throws* IOException
>
> */
>
> *public* *void* revisarNodos(Element document, String formName) *throws*
> IOException {
>
> InputStream is =
> getClass().getResourceAsStream("plantilla_"+formName+".xml");
>
> Document plantilla = *null*;
>
> *try* {
>
> plantilla = Dom4jUtils./readDom4j/(is);
>
> } *catch* (SAXException e) {
>
> *throw* *new* IOException(e.getMessage());
>
> } *catch* (DocumentException e) {
>
> *throw* *new* IOException(e.getMessage());
>
> }
>
> //Recorremos y comparamos ambos documentos
>
> Element raizPlantilla = plantilla.getRootElement();
>
> //Revisamos los hijos de forma recursiva
>
> revisarHijos(raizPlantilla, document);
>
>  
>
> }
>
> /**
>
> * Revisa los hijos de dos elementos e inserta los nodos que le falten al
> segundo sobre el primero
>
> * *@param* elementoPlantilla
>
> * *@param* elementoDocumento
>
> */
>
> *private* *void* revisarHijos(Element elementoPlantilla, Element
> elementoDocumento) {
>
> *int* posicion = 0;
>
> Iterator it = elementoPlantilla.elementIterator();
>
> *while* ( it.hasNext() ) {
>
> Element hijoPlantilla = (Element) it.next();
>
> //Buscamos ese elemento en el documento
>
> Element hijoDocumento = (Element)
> elementoDocumento.selectSingleNode(hijoPlantilla.getName());
>
> //Si el elemento no existe lo añadimos, si existe lo revisamos
>
> *if* (hijoDocumento == *null*) {
>
> elementoDocumento.content().add(posicion, hijoPlantilla);
>
> }
>
> *else* {
>
> revisarHijos(hijoPlantilla, hijoDocumento);
>
> }
>
> posicion++;
>
> }
>
> }
>  
> I hope this can help somebody.
>  
> Thank you and regards
>
>     ------------------------------------------------------------------------
>     From: [hidden email]
>     To: [hidden email]
>     Date: Thu, 12 Jul 2007 15:34:16 +0100
>     Subject: RE: [ops-users] display input if its ref don't exist
>
>     Hello!
>      
>     I've back to work with this "problem" but I can found a good solution.
>      
>     We have a big xml with a lot of possible missing fields. So
>     pre-process that xml is very hard.
>      
>     And we have a lot of input field (but we don't know when this input
>     has to be bound to a node). And we can't add a but in each input,
>     because is not very clear.
>      
>     Do you know if it's possible another solution?? Perhaps add all this
>     missing fields in a xforms-ready event o in a onchange event o...
>      
>     That's very important for us. Thank you very much in advance.
>
>      > Date: Fri, 29 Jun 2007 12:04:01 +0200
>      > From: [hidden email]
>      > To: [hidden email]
>      > Subject: Re: [ops-users] display input if its ref don't exist
>      >
>      > In XForms, a control that captures data has to be bound to a node,
>      > otherwise it is considered non-relevant, i.e. not accessible to
>     the user
>      > (in this case it is usually invisible, or grayed out).
>      >
>      > If you want, XML data nodes are like variables holding control
>     values.
>      > This is a fundamental aspect of XForms and it's hard to change it.
>      >
>      > I think you have a few options:
>      >
>      > * Do what you suggested, i.e. pre-process your XML document to
>     add the
>      > missing fields.
>      >
>      > * Use an "Add phone number" button which uses xforms:insert to
>     add the
>      > telephone2 field.
>      >
>      > -Erik
>      >
>      > aa aa wrote:
>      > > Thank you very much, now I undestand the problem.
>      > >
>      > > Of course I would like to stored the data. But sometimes we
>     receive a
>      > > xml without any node. Por example:
>      > >
>      > > This is a complete xml:
>      > >
>      > > <document>
>      > > <telephone1>12345</telephone1>
>      > > <telephone2>54321</telephone2>
>      > > </document>
>      > >
>      > > An this one is a case when the person only have one telephone:
>      > >
>      > > <document>
>      > > <telephone1>12345</telephone1>
>      > > </document>
>      > >
>      > > But in the form we always want to display both inputs. What we
>     can do
>      > > when we receive the second xml?? We have to preprocess the xml
>     and add
>      > > "<telephone2/>"? This is very complecated in a big xml with a
>     lot of
>      > > nodes...
>      > >
>      > > Thank you in advance!
>      > >
>      > > > Date: Thu, 28 Jun 2007 16:21:27 -0700
>      > > > From: [hidden email]
>      > > > To: [hidden email]
>      > > > Subject: Re: [ops-users] display input if its ref don't exist
>      > > >
>      > > > On 6/27/07, aa aa <[hidden email]> wrote:
>      > > > > I want to can click in it and enter data.
>      > > > >
>      > > > > Sometimes we have a incomplete xml, but we want to see all
>     the inputs.
>      > > >
>      > > > But what happens if you enter data? It won't have anywhere to go,
>      > > > since there is no node to which the input is bound and where
>     the data
>      > > > could be stored. Is this what you want?
>      > > >
>      > > > Alex
>      > > > --
>      > > > Orbeon Forms - Web 2.0 Forms, open-source, for the Enterprise
>      > > > http://www.orbeon.com/
>      > > >
>      > >
>      > >
>      > >
>     ------------------------------------------------------------------------
>      > > Busca desde cualquier página Web con una protección excepcional.
>      > > Consigue la Barra de herramientas de Windows Live hoy mismo
>      > > GRATUITAMENTE. Pruébalo <http://www.toolbar.live.com>
>      > >
>      >
>      >
>      > --
>      > Orbeon Forms - Web Forms for the Enterprise Done the Right Way
>      > http://www.orbeon.com/
>      >
>
>
>     ------------------------------------------------------------------------
>     Prueba algunos de los nuevos servicios en línea que te ofrece
>     Windows Live Ideas: tan nuevos que ni siquiera se han publicado
>     oficialmente todavía. Pruébalo <http://ideas.live.com/>
>
>
> ------------------------------------------------------------------------
> Llama a tus amigos de PC a PC: ¡Es GRATIS! Pruébalo
> <http://get.live.com/messenger/overview>
>

--
Orbeon Forms - Web Forms for the Enterprise Done the Right Way
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