You are messing up things,
Digester knows anything about servlets, contexts, session or requests.
I supose you have
public void addAbfrage(Abfrage beanObject)
in the Abfragen class.You have ONLY to do 2 things:
1. put that in your servlet ( the class that contains your initSQLRules() method)
protected Hashtable abfragenContainer = new Hashtable();
public void addAbfragen(Abfragen beanContainerObject) {
abfragenContainer.put("Abfragen", beanContainerObject);
}
public void initSQLRules()
{
try
{
Digester digester = new Digester();
digester.push(this);
digester.addObjectCreate("Abfragen",Abfragen.class);
digester.addObjectCreate("Abfragen/Abfrage",Abfrage.class);
digester.addBeanPropertySetter("Abfragen/Abfrage/Name","name");
digester.addBeanPropertySetter("Abfragen/Abfrage/SQL","wert");
digester.addSetNext("Abfragen/Abfrage","addAbfrage");
digester.addSetNext("Abfragen","addAbfragen");
digester.parse("my.xml"); }
catch (Exception e)
{
e.printStackTrace();
}
}
2. to get the Abfragen object :
.........
Abfragen myAbfragen = (Abfragen)abfragenContainer.get("Abfragen");
...........Frank Schaare wrote:
Hi Jos�,
I'll try to explain as far as my knowdledge of Digester and my english skills could.
Your english seems to be much better then mine ;-)
My article of reference is O'Reilly's one : http://www.onjava.com/lpt/a/2746
This is the first of three articles found on digesters home. In fact, most of my code ist taken from this article
digester.addObjectCreate("Abfragen",Abfragen.class);
When <Abfragen> is found create a new Abfragen object and put it on top of stack ( above 'this' )
I�m totally confused about this stack . How can i access this Abfragen(Bean) ? I expectet something like:
getServletContext().getAttribute("Abfragen");
seesion.getAttribute("Abfragen"); or
request.getAttribute("Abfragen");
But what about the stack ?
if the Abfragen class has a method called public void addAbfrage(Abfrage beanObject) you will found your beans there.
hmm, but therefore, i need the Abfragen-instance. Is there a getter for the stack ?
digester.addSetNext("Abfragen","addAbfragen");
and add that method
public void addAbfragen(Abfragen beanContainerObject)
to your servlet.
Digester will call it and pass the newly created Abfragen instance and you will have everything at your disposition.
do you have a code example for this ? When i digest the xml file, i�m in ActionServlets init() method. Do i have to add another method like your description ?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------------------------- Este correo electr�nico y, en su caso, cualquier fichero anexo al mismo, contiene informaci�n de car�cter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgaci�n, copia o distribuci�n a terceros sin la previa autorizaci�n escrita de Indra. En el caso de haber recibido este correo electr�nico por error, se ruega notificar inmediatamente esta circunstancia mediante reenv�o a la direcci�n electr�nica del remitente.
The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
