RE: XMLForm: content listbox problem

2002-12-10 Thread Sylvain.Thevoz
Hi Ivelin,

Thanks for your suggestions.

Do you create this method in the Bean file or Action file?

What does the method should return? The dom document?

Thank you
Regards
Sylvain


-Message d'origine-
De: Ivelin Ivanov [mailto:[EMAIL PROTECTED]]
Date: lundi, 9. décembre 2002 20:49
À: [EMAIL PROTECTED]
Objet: Re: XMLForm: content listbox problem



The best place to do a one-time initialization of the data model is the
getFormModel() method.
This is the orginial in the AbstractXMLFormAction:

  /**
   * Extract xmlform-model
   * action parameter and
   * instantiate a new form model it.
   *
   *
   * Subclasses may override this method
   * to use custom model instantiation technique
   *
   */
  protected Object getFormModel()
  {
try
  {
String modelClassName =
getParameters().getParameter(xmlform-model, null);
Class modelClass = Class.forName ( modelClassName );
Object o = modelClass.newInstance ();
return o;
  }
  catch ( Exception e)
  {
throw new CascadingRuntimeException(  Failed instantiating form
model , e );
  }
  }


You can override this method and do the following:

  protected Object getFormModel()
  {
// create a dom document and initialize it
// preferably use the JXPath DocumentContainer
  }


This way, the first XMLForm page will use the initialized version.


Let me know if this works for you.



Ivelin



- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, December 09, 2002 10:13 AM
Subject: RE: XMLForm: content listbox problem


Hi Lars,

You said that I should initialize the bean in the prepare method.
What do you do exactly?

For my Bean I started from the Wizard example code. The initialization is in
the perform method.

regards
Thank you
Sylvain



-Message d'origine-
De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
Date: lundi, 9. décembre 2002 09:38
À: '[EMAIL PROTECTED]'
Objet: AW: XMLForm: content listbox problem


I'm sorry confusing you with this. This are just integer values
which returns me how the function was executed.

That means getTransactionData returns an integer value with the
number of elements. So that I can decide on this what should be
done next. (I'm new to cocoon and java as well and am not sure
if this is a correct or good way to do, but it works for me now,
if anybody has a clearer or better aproach I would be very pleased
to know about it)

public int getTransactionData() {
...
return numberOfTransactions;
}

so try to initialize the bean in the prepare method as well and see
whats happening.

ciao Lars


 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Gesendet: Montag, 9. Dezember 2002 16:28
 An: [EMAIL PROTECTED]
 Betreff: RE: XMLForm: content listbox problem


 Hello Lars,

 I call the getModel() method in the perform function, like
 the Wizard example:

 code
 public Map perform() {
   AddWorkstationBean jBean = (AddWorkstationBean)
 getForm().getModel();
   if (getCommand().equals(CMD_NEXT)
 getForm().getViolations() != null) {
 return page(getFormView());
   } else {
 getForm().clearViolations();
 String command = getCommand();
 String formView = getFormView();

 if (formView.equals(VIEW_FORM1)) {
   if (command.equals(CMD_NEXT)) {
   return page(VIEW_FORM2);
 }
 } else if (formView.equals(VIEW_FORM
 ..
 etc
 ..
 code

 I don't understand what mean the result_trans and result_cust
 properties. Are they Bean properties?

 Thank you
 Regards
 Sylvain





 -Message d'origine-
 De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
 Date: lundi, 9. décembre 2002 03:32
 À: '[EMAIL PROTECTED]'
 Objet: AW: XMLForm: content listbox problem


 Hello Sylvian,

 I always initialize the data for the appropriate form. This means
 I put the initialize data actions in different functions and call
 them if I reach the stage.  Here is an example:

 - code
 if ( formView.equals ( VIEW_START ) ) {
   if ( command.equals( CMD_COMMIT ) ) {
   int result_trans =
 jBean.getTransactionData();
   int result_cust = jBean.getUserData();

   if ( result_cust == 0 ) {
   return page( VIEW_ERROR );
   }
   else if ( result_trans == 0 ) {
   return page( VIEW_ERROR );
   }

  else if ( result_cust  1 ) {
  return page( VIEW_CUSTOMER );
  }
  else {
  return page( VIEW_INVOICE );
  }
 }
 }
 - /code

 this allows me also to react on different results from these
 functions.
 When did you call the getModel() method from the bean?  Are you doing
 that in the prepare or perform function?

 ciao Lars

  -Ursprüngliche Nachricht-
  Von: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED]]
  Gesendet: Freitag, 6. Dezember 2002 00:01
  An: [EMAIL PROTECTED]
  Betreff: XMLForm: content listbox problem
 
 
  Hello,
 
  I have an XMLForm app like this:
 
  Navigation:
  Start-Form1-Form2-Confirm-End
 
  In the Form1 view I

Re: XMLForm: content listbox problem

2002-12-10 Thread Ivelin Ivanov

- Original Message - 
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, December 10, 2002 2:19 AM
Subject: RE: XMLForm: content listbox problem


 Do you create this method in the Bean file or Action file?

In the Action.

 What does the method should return? The dom document?

In your case, it should return a DocumentContainer, not a DOM object.
See
http://jakarta.apache.org/commons/jxpath/users-guide.html#Containers



Ivelin


-
Please check that your question  has not already been answered in the
FAQ before posting. http://xml.apache.org/cocoon/faq/index.html

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:   [EMAIL PROTECTED]




RE: XMLForm: content listbox problem

2002-12-09 Thread Sylvain.Thevoz
Hello Lars,

I call the getModel() method in the perform function, like the Wizard example:

code
public Map perform() {
  AddWorkstationBean jBean = (AddWorkstationBean) getForm().getModel();
  if (getCommand().equals(CMD_NEXT) getForm().getViolations() != null) {
return page(getFormView());
  } else {
getForm().clearViolations();
String command = getCommand();
String formView = getFormView();

if (formView.equals(VIEW_FORM1)) {
  if (command.equals(CMD_NEXT)) {
  return page(VIEW_FORM2);
}
} else if (formView.equals(VIEW_FORM
..
etc
..
code

I don't understand what mean the result_trans and result_cust properties. Are they 
Bean properties?

Thank you
Regards
Sylvain





-Message d'origine-
De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
Date: lundi, 9. décembre 2002 03:32
À: '[EMAIL PROTECTED]'
Objet: AW: XMLForm: content listbox problem


Hello Sylvian,

I always initialize the data for the appropriate form. This means 
I put the initialize data actions in different functions and call
them if I reach the stage.  Here is an example:

- code
if ( formView.equals ( VIEW_START ) ) {
if ( command.equals( CMD_COMMIT ) ) {
int result_trans= jBean.getTransactionData();
int result_cust = jBean.getUserData();

if ( result_cust == 0 ) {
return page( VIEW_ERROR );  
}   
else if ( result_trans == 0 ) {
return page( VIEW_ERROR );  
}

else if ( result_cust  1 ) {
return page( VIEW_CUSTOMER );
}
else {
return page( VIEW_INVOICE );
}
}
}
- /code

this allows me also to react on different results from these functions.
When did you call the getModel() method from the bean?  Are you doing 
that in the prepare or perform function?

ciao Lars

 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Gesendet: Freitag, 6. Dezember 2002 00:01
 An: [EMAIL PROTECTED]
 Betreff: XMLForm: content listbox problem
 
 
 Hello,
 
 I have an XMLForm app like this:
 
 Navigation:
 Start-Form1-Form2-Confirm-End
 
 In the Form1 view I have a listbox. The content (the 
 different choices) of this listbox comes from an XML file. 
 The code is:
 xf:selectOne ref=/workstationType
   xf:captionWorkstation Type/xf:caption
   xf:itemset nodeset=select/document/typeOfWorkstation/item
 xf:caption ref=description/
 xf:value ref=@id/
   /xf:itemset
   xf:violations class=error/
 /xf:selectOne
 
 This code seems to be OK. The XPath code is also OK I think. 
 Here is the XML file:
 document
   typeOfWorkstation
 item id=desktop
   descriptionDesktop/description
 /item
 item id=laptop
   descriptionLaptop/description
 /item
 item id=other
   descriptionOther configuration/description
 /item
   /typeOfWorkstation
 /document
 
 
 I load the XML file in a DOM Node property (called select). 
 This property is located in the Bean file (with getter and 
 setter methods for this property). I load the XML file in 
 this Node property also in the Bean file, in the constructor. 
 Here the Bean file:
 
 public class AddWorkstationBean {
   private String workstationName;
   private String workstationType;
   private String workstationOwner;
   private String workstationUser;
 
   private Node select; //values from the XML file
 
   public AddWorkstationBean() {
   initSelect();
   }
 
   public Node initSelect() {
   //initialize a property named select of DOM Node class
   DOMImplementation impl;
   try {
   // Find the implementation
   DocumentBuilderFactory factory =
   DocumentBuilderFactory.newInstance();
   factory.setNamespaceAware(false);
   factory.setValidating(false);
   DocumentBuilder builder = 
 factory.newDocumentBuilder();
   impl = builder.getDOMImplementation();
 
   //Create the node for the root select
   Document document = 
 impl.createDocument(null, select, null);
   Node selectName = document.getDocumentElement();
 
   //Loading from XML File
   String fileName =
   
 C:\\jakarta-tomcat-4.1.12\\webapps\\cocoon\\woc\\iniForm.xml;
   FileInputStream inXML = new 
 FileInputStream(fileName);
   

RE: XMLForm: content listbox problem

2002-12-09 Thread Sylvain.Thevoz
I tried to initialize the bean in the prepare method but it's still the same!
Nothing happen!

I posted 2 different messages(content list box problem and DOM initialization problem) 
but the problem is the same.


Sylvain


-Message d'origine-
De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
Date: lundi, 9. décembre 2002 09:38
À: '[EMAIL PROTECTED]'
Objet: AW: XMLForm: content listbox problem


I'm sorry confusing you with this. This are just integer values 
which returns me how the function was executed. 

That means getTransactionData returns an integer value with the 
number of elements. So that I can decide on this what should be 
done next. (I'm new to cocoon and java as well and am not sure 
if this is a correct or good way to do, but it works for me now,
if anybody has a clearer or better aproach I would be very pleased
to know about it)

public int getTransactionData() {
...
return numberOfTransactions;
}

so try to initialize the bean in the prepare method as well and see
whats happening.

ciao Lars


 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Gesendet: Montag, 9. Dezember 2002 16:28
 An: [EMAIL PROTECTED]
 Betreff: RE: XMLForm: content listbox problem
 
 
 Hello Lars,
 
 I call the getModel() method in the perform function, like 
 the Wizard example:
 
 code
 public Map perform() {
   AddWorkstationBean jBean = (AddWorkstationBean) 
 getForm().getModel();
   if (getCommand().equals(CMD_NEXT) 
 getForm().getViolations() != null) {
   return page(getFormView());
   } else {
 getForm().clearViolations();
 String command = getCommand();
 String formView = getFormView();
 
 if (formView.equals(VIEW_FORM1)) {
   if (command.equals(CMD_NEXT)) {
 return page(VIEW_FORM2);
   }
   } else if (formView.equals(VIEW_FORM
 ..
 etc
 ..
 code
 
 I don't understand what mean the result_trans and result_cust 
 properties. Are they Bean properties?
 
 Thank you
 Regards
 Sylvain
 
 
 
 
 
 -Message d'origine-
 De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
 Date: lundi, 9. décembre 2002 03:32
 À: '[EMAIL PROTECTED]'
 Objet: AW: XMLForm: content listbox problem
 
 
 Hello Sylvian,
 
 I always initialize the data for the appropriate form. This means 
 I put the initialize data actions in different functions and call
 them if I reach the stage.  Here is an example:
 
 - code
   if ( formView.equals ( VIEW_START ) ) {
   if ( command.equals( CMD_COMMIT ) ) {
   int result_trans= 
 jBean.getTransactionData();
   int result_cust = jBean.getUserData();
   
   if ( result_cust == 0 ) {
   return page( VIEW_ERROR );  
   }   
   else if ( result_trans == 0 ) {
   return page( VIEW_ERROR );  
   }
   
   else if ( result_cust  1 ) {
   return page( VIEW_CUSTOMER );
   }
   else {
   return page( VIEW_INVOICE );
   }
   }
   }
 - /code
 
 this allows me also to react on different results from these 
 functions.
 When did you call the getModel() method from the bean?  Are you doing 
 that in the prepare or perform function?
 
 ciao Lars
 
  -Ursprüngliche Nachricht-
  Von: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED]]
  Gesendet: Freitag, 6. Dezember 2002 00:01
  An: [EMAIL PROTECTED]
  Betreff: XMLForm: content listbox problem
  
  
  Hello,
  
  I have an XMLForm app like this:
  
  Navigation:
  Start-Form1-Form2-Confirm-End
  
  In the Form1 view I have a listbox. The content (the 
  different choices) of this listbox comes from an XML file. 
  The code is:
  xf:selectOne ref=/workstationType
xf:captionWorkstation Type/xf:caption
xf:itemset nodeset=select/document/typeOfWorkstation/item
  xf:caption ref=description/
  xf:value ref=@id/
/xf:itemset
xf:violations class=error/
  /xf:selectOne
  
  This code seems to be OK. The XPath code is also OK I think. 
  Here is the XML file:
  document
typeOfWorkstation
  item id=desktop
descriptionDesktop/description
  /item
  item id=laptop
descriptionLaptop/description
  /item
  item id=other
descriptionOther configuration/description
  /item
/typeOfWorkstation
  /document
  
  
  I load the XML file in a DOM Node property (called select). 
  This property is located in the Bean file (with getter and 
  setter methods for this property). I load the XML file in 
  this Node property also in the Bean file, in the constructor. 
  Here the Bean file:
  
  public class

RE: XMLForm: content listbox problem

2002-12-09 Thread Sylvain.Thevoz
Hi Lars,

You said that I should initialize the bean in the prepare method.
What do you do exactly?

For my Bean I started from the Wizard example code. The initialization is in the 
perform method.

regards
Thank you
Sylvain



-Message d'origine-
De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
Date: lundi, 9. décembre 2002 09:38
À: '[EMAIL PROTECTED]'
Objet: AW: XMLForm: content listbox problem


I'm sorry confusing you with this. This are just integer values 
which returns me how the function was executed. 

That means getTransactionData returns an integer value with the 
number of elements. So that I can decide on this what should be 
done next. (I'm new to cocoon and java as well and am not sure 
if this is a correct or good way to do, but it works for me now,
if anybody has a clearer or better aproach I would be very pleased
to know about it)

public int getTransactionData() {
...
return numberOfTransactions;
}

so try to initialize the bean in the prepare method as well and see
whats happening.

ciao Lars


 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Gesendet: Montag, 9. Dezember 2002 16:28
 An: [EMAIL PROTECTED]
 Betreff: RE: XMLForm: content listbox problem
 
 
 Hello Lars,
 
 I call the getModel() method in the perform function, like 
 the Wizard example:
 
 code
 public Map perform() {
   AddWorkstationBean jBean = (AddWorkstationBean) 
 getForm().getModel();
   if (getCommand().equals(CMD_NEXT) 
 getForm().getViolations() != null) {
   return page(getFormView());
   } else {
 getForm().clearViolations();
 String command = getCommand();
 String formView = getFormView();
 
 if (formView.equals(VIEW_FORM1)) {
   if (command.equals(CMD_NEXT)) {
 return page(VIEW_FORM2);
   }
   } else if (formView.equals(VIEW_FORM
 ..
 etc
 ..
 code
 
 I don't understand what mean the result_trans and result_cust 
 properties. Are they Bean properties?
 
 Thank you
 Regards
 Sylvain
 
 
 
 
 
 -Message d'origine-
 De: Kirchhoff, Lars [mailto:[EMAIL PROTECTED]]
 Date: lundi, 9. décembre 2002 03:32
 À: '[EMAIL PROTECTED]'
 Objet: AW: XMLForm: content listbox problem
 
 
 Hello Sylvian,
 
 I always initialize the data for the appropriate form. This means 
 I put the initialize data actions in different functions and call
 them if I reach the stage.  Here is an example:
 
 - code
   if ( formView.equals ( VIEW_START ) ) {
   if ( command.equals( CMD_COMMIT ) ) {
   int result_trans= 
 jBean.getTransactionData();
   int result_cust = jBean.getUserData();
   
   if ( result_cust == 0 ) {
   return page( VIEW_ERROR );  
   }   
   else if ( result_trans == 0 ) {
   return page( VIEW_ERROR );  
   }
   
   else if ( result_cust  1 ) {
   return page( VIEW_CUSTOMER );
   }
   else {
   return page( VIEW_INVOICE );
   }
   }
   }
 - /code
 
 this allows me also to react on different results from these 
 functions.
 When did you call the getModel() method from the bean?  Are you doing 
 that in the prepare or perform function?
 
 ciao Lars
 
  -Ursprüngliche Nachricht-
  Von: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED]]
  Gesendet: Freitag, 6. Dezember 2002 00:01
  An: [EMAIL PROTECTED]
  Betreff: XMLForm: content listbox problem
  
  
  Hello,
  
  I have an XMLForm app like this:
  
  Navigation:
  Start-Form1-Form2-Confirm-End
  
  In the Form1 view I have a listbox. The content (the 
  different choices) of this listbox comes from an XML file. 
  The code is:
  xf:selectOne ref=/workstationType
xf:captionWorkstation Type/xf:caption
xf:itemset nodeset=select/document/typeOfWorkstation/item
  xf:caption ref=description/
  xf:value ref=@id/
/xf:itemset
xf:violations class=error/
  /xf:selectOne
  
  This code seems to be OK. The XPath code is also OK I think. 
  Here is the XML file:
  document
typeOfWorkstation
  item id=desktop
descriptionDesktop/description
  /item
  item id=laptop
descriptionLaptop/description
  /item
  item id=other
descriptionOther configuration/description
  /item
/typeOfWorkstation
  /document
  
  
  I load the XML file in a DOM Node property (called select). 
  This property is located in the Bean file (with getter and 
  setter methods for this property). I load the XML file in 
  this Node property also in the Bean file, in the constructor. 
  Here the Bean file:
  
  public class