You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Derek Hohls <DH...@csir.co.za> on 2008/04/16 15:28:03 UTC

Processing dynamically-created forms

Working with Cocoon 2.1.8
 
I am looking for examples or guides on how to post-process a form
that will have been created dynamically i.e. it won't be possible
to know in advance which fields appear or what they are called.
 
I know how to create such a form, but not how to "get at" the data
it will contain.
 
Normally, in flowscript, I would access a field value in a form with the
  model.Fieldname
notation... but without knowing what those fieldnames will be, I am unsure
of how to proceed.
 
Any help or pointers appreciated!
 
Thanks
Derek


-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Derek Hohls pisze:
> Grzegorz
> 
> No, I have not.  I have not used this before; is there any sample
> code of how to work with the java widget iterator?

Not that I'm aware of but it's really not rocket science here. Maybe you got confused about java 
widget iterator. All I meant was that you will get object implementing Iterator[1] interface so you 
can use it as any other iterator in the loop.

The code sample in JS should look like:
for (var it = formmodel.children; it.hasNext(); var widget = it.next()) {
   //do whatever you want with widget here
}


[1] http://java.sun.com/j2se/1.4.2/docs/api/java/util/Iterator.html

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Derek Hohls <DH...@csir.co.za>.
Grzegorz

No, I have not.  I have not used this before; is there any sample
code of how to work with the java widget iterator?

Thanks
Derek

>>> On 2008/04/18 at 11:23, in message <48...@tuffmail.com>, Grzegorz Kossakowski <gr...@tuffmail.com> wrote:
Derek Hohls pisze:
> Working with Cocoon 2.1.8
>  
> I am looking for examples or guides on how to post-process a form
> that will have been created dynamically i.e. it won't be possible
> to know in advance which fields appear or what they are called.
>  
> I know how to create such a form, but not how to "get at" the data
> it will contain.
>  
> Normally, in flowscript, I would access a field value in a form with the
>   model.Fieldname
> notation... but without knowing what those fieldnames will be, I am unsure
> of how to proceed.

Hi Derek,

Have you tried:

  var it = model.children

Where it will hold Java iterator over widgets that model contains.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Derek Hohls <DH...@csir.co.za>.
Grzegorz
 
I finally managed to find the answer - its mentioned here:
http://mail-archives.apache.org/mod_mbox/cocoon-users/200708.mbox/%3C46B12CD0.60000@lojjic.net%3E 

Basically you need to use:
var myWidgets = myForm.getWidget().getChildren();

So, for the record, my complete code looks like:

if (myForm.getWidget().getSubmitWidget().getId().equals("ok")) {
 var it = myForm.getWidget().getChildren();
 if ( it != null ) {
  var fwidget = null;
  var ID  = null;
  var val = null;  
  while ( it.hasNext() ) {  
   fwidget = it.next() ; 
   ID = fwidget.getId();
   if ( (ID!=null) && (ID!="ok") && (ID!="cancel") && (ID!="message") ) {
    val = fwidget.getValue();
    if ( val!=null ) { 
     //process a widget that has a value...
    } 
   }
  }   
 }
}

HTH someone!

Derek


>>> On 2008/04/27 at 03:39, in message <48...@tuffmail.com>, Grzegorz Kossakowski <gr...@tuffmail.com> wrote:
Derek Hohls pisze:
> Can anyone help with this?! - 
> I am sure its a simple syntax issue...
> 
>>>> On 2008/04/21 at 12:40, in message <48...@csir.co.za>, "Derek Hohls" <DH...@csir.co.za> wrote:
> Gregorz
> 
> Unfortunately, when I try:
> 
> var it = model.children;
> 
> it has an "undefined" (null) result, not an iterator.
> 
> I also tried:
> 
> var it = myform.getChildren();
> 
> but without success.
> 
> Any ideas  how to get this to work?  I have tried this in 
> different flowscripts for different forms; all have the
> same problem.

Hi Derek,

Thanks for reminding me. I'm just developing some Forms so I'll try my suggestion and see why it's 
not working. Stay tuned.

-- 
Best regards,
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Derek Hohls pisze:
> Can anyone help with this?! - 
> I am sure its a simple syntax issue...
> 
>>>> On 2008/04/21 at 12:40, in message <48...@csir.co.za>, "Derek Hohls" <DH...@csir.co.za> wrote:
> Gregorz
> 
> Unfortunately, when I try:
> 
> var it = model.children;
> 
> it has an "undefined" (null) result, not an iterator.
> 
> I also tried:
> 
> var it = myform.getChildren();
> 
> but without success.
> 
> Any ideas  how to get this to work?  I have tried this in 
> different flowscripts for different forms; all have the
> same problem.

Hi Derek,

Thanks for reminding me. I'm just developing some Forms so I'll try my suggestion and see why it's 
not working. Stay tuned.

-- 
Best regards,
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Derek Hohls <DH...@csir.co.za>.
Can anyone help with this?! - 
I am sure its a simple syntax issue...

>>> On 2008/04/21 at 12:40, in message <48...@csir.co.za>, "Derek Hohls" <DH...@csir.co.za> wrote:
Gregorz

Unfortunately, when I try:

var it = model.children;

it has an "undefined" (null) result, not an iterator.

I also tried:

var it = myform.getChildren();

but without success.

Any ideas  how to get this to work?  I have tried this in 
different flowscripts for different forms; all have the
same problem.

Thanks
Derek


>>> On 2008/04/18 at 11:23, in message <48...@tuffmail.com>, Grzegorz Kossakowski <gr...@tuffmail.com> wrote:
Derek Hohls pisze:
> Working with Cocoon 2.1.8
>  
> I am looking for examples or guides on how to post-process a form
> that will have been created dynamically i.e. it won't be possible
> to know in advance which fields appear or what they are called.
>  
> I know how to create such a form, but not how to "get at" the data
> it will contain.
>  
> Normally, in flowscript, I would access a field value in a form with the
>   model.Fieldname
> notation... but without knowing what those fieldnames will be, I am unsure
> of how to proceed.

Hi Derek,

Have you tried:

  var it = model.children

Where it will hold Java iterator over widgets that model contains.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Derek Hohls <DH...@csir.co.za>.
Gregorz
 
Unfortunately, when I try:

var it = model.children;

it has an "undefined" (null) result, not an iterator.

I also tried:

var it = myform.getChildren();

but without success.

Any ideas  how to get this to work?  I have tried this in 
different flowscripts for different forms; all have the
same problem.

Thanks
Derek


>>> On 2008/04/18 at 11:23, in message <48...@tuffmail.com>, Grzegorz Kossakowski <gr...@tuffmail.com> wrote:
Derek Hohls pisze:
> Working with Cocoon 2.1.8
>  
> I am looking for examples or guides on how to post-process a form
> that will have been created dynamically i.e. it won't be possible
> to know in advance which fields appear or what they are called.
>  
> I know how to create such a form, but not how to "get at" the data
> it will contain.
>  
> Normally, in flowscript, I would access a field value in a form with the
>   model.Fieldname
> notation... but without knowing what those fieldnames will be, I am unsure
> of how to proceed.

Hi Derek,

Have you tried:

  var it = model.children

Where it will hold Java iterator over widgets that model contains.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org 
For additional commands, e-mail: users-help@cocoon.apache.org 



-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their support.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Processing dynamically-created forms

Posted by Grzegorz Kossakowski <gr...@tuffmail.com>.
Derek Hohls pisze:
> Working with Cocoon 2.1.8
>  
> I am looking for examples or guides on how to post-process a form
> that will have been created dynamically i.e. it won't be possible
> to know in advance which fields appear or what they are called.
>  
> I know how to create such a form, but not how to "get at" the data
> it will contain.
>  
> Normally, in flowscript, I would access a field value in a form with the
>   model.Fieldname
> notation... but without knowing what those fieldnames will be, I am unsure
> of how to proceed.

Hi Derek,

Have you tried:

  var it = model.children

Where it will hold Java iterator over widgets that model contains.

-- 
Grzegorz Kossakowski

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org