cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kirchhoff, Lars" <Lars.Kirchh...@wincor-nixdorf.com>
Subject AW: XMLForm: content listbox problem
Date Mon, 09 Dec 2002 08:37:30 GMT
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: Sylvain.Thevoz@swisscom.com [mailto:Sylvain.Thevoz@swisscom.com]
> Gesendet: Montag, 9. Dezember 2002 16:28
> An: cocoon-users@xml.apache.org
> 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:Lars.Kirchhoff@wincor-nixdorf.com]
> Date: lundi, 9. décembre 2002 03:32
> À: 'cocoon-users@xml.apache.org'
> 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: Sylvain.Thevoz@swisscom.com 
> [mailto:Sylvain.Thevoz@swisscom.com]
> > Gesendet: Freitag, 6. Dezember 2002 00:01
> > An: cocoon-users@xml.apache.org
> > 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:caption>Workstation 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">
> >       <description>Desktop</description>
> >     </item>
> >     <item id="laptop">
> >       <description>Laptop</description>
> >     </item>
> >     <item id="other">
> >       <description>Other 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);
> > 			BufferedReader in =
> > 				new BufferedReader(new 
> > InputStreamReader(inXML));
> > 			Element element = XMLLoader.loadFromStream(in);
> > 
> > 			//Import the node
> > 			Element importedElement =
> > 				(Element) 
> > document.importNode(element, true);
> > 			selectName.appendChild(importedElement);
> > 
> > 			//initialize the porperty
> > 			
> > 			select = selectName;
> > 	}
> >  
> > .. getter an setter methods..
> > ..
> > 
> > }
> > 	
> > 
> > My problem is when I start the app (with the Start view) and 
> > then display the Form1 there is NOTHING in the listbox (the 
> > list isn't empty but it's like the caption and value 
> > properties are null)!!
> > Then I go to the next view (Form2). Then if I press the 
> > Preview button and go back to the Form1, the listbox is OK!! 
> > It's crazy and I really don't understand why!
> > 
> > Someone could help me?
> > Any suggestions will be greatly appreciated!
> > 
> > Thank you
> > Sylvain
> > 
> > 
> ---------------------------------------------------------------------
> > 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:     
> <cocoon-users-unsubscribe@xml.apache.org>
> > For additional commands, e-mail:   
> <cocoon-users-help@xml.apache.org>
> > 
> 
> ---------------------------------------------------------------------
> 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:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> 
> 
> ---------------------------------------------------------------------
> 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:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> 

---------------------------------------------------------------------
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:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message