You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "Afshartous, Nick" <Ni...@WorkStreamInc.com> on 2006/02/06 21:55:57 UTC

using submitted form value with validator

 Hi,

I was wondering how to pass a submitted form value to be used

as part of a validator error message.

For instance, for the message

    errors.email={0} is an invalid e-mail address.

how would specify what would  fill in the {0} argument.

Thanks.

      Nick

 

 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [betwixt] Exception suppression

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Tue, 2006-03-07 at 17:21 -0500, Igor Marakov wrote:
> Robert,
> Do you have an approximate list of exceptions that SHOULD be handled by
> betwixt?

i'm not sure a general list is possible: the semantics of each method
mean that it would need to be done on a case-by-case basis. for some
APIs, an exception may indicate that the object is basically DOA, others
may throw exceptions when the input is outside acceptable bounds. there
are also some APIs which throw exceptions to communicate unusual
circumstances which are not necessarily errors. in this last case, users
may not want the mapping to terminate.

if i'd have designed the interface, i would probably have defaulted to
rethrowing all target exceptions but i'd have been wrong. this is
probably something that should be configurable: factor out a strategy
for processing the exception. have a switch in the configuration and let
users choose.

- robert


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [betwixt] Exception suppression

Posted by Igor Marakov <ig...@ivmsystems.com>.
Robert,
Do you have an approximate list of exceptions that SHOULD be handled by
betwixt?

Thanks,
Igor

-----Original Message-----
From: robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk] 
Sent: Tuesday, March 07, 2006 5:06 PM
To: Jakarta Commons Users List
Subject: Re: [betwixt] Exception suppression

On Tue, 2006-03-07 at 11:13 -0500, Igor Marakov wrote:
> I recently ran into the situation where betwixt is suppressing exceptions
> during the translation.
> I don't think it is a good idea. 
> Enclosing application code should be aware that data that it expecting
ain't
> coming. Here is the example of the unsuccessful translation of the SQLJ
> object that is coming from the DB and is supposed to be translated into
the
> normal java bean. Translation fails due to SQLException, but application
> code is not getting any indication of it.
> 
> Question: Is there the way to switch this behavior off or limit it to
> certain kinds of exceptions?

AFAIK not at the moment but this should be possible to add this
functionality without too much knowledge of the code. managing the
difficult JCL 1.1 release is taking most of my time ATM so not sure when
i'd find time to code this.

anyone want to volunteer to create a patch?

(i'd be glad to answer questions)

- robert



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [betwixt] Exception suppression

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
On Tue, 2006-03-07 at 11:13 -0500, Igor Marakov wrote:
> I recently ran into the situation where betwixt is suppressing exceptions
> during the translation.
> I don't think it is a good idea. 
> Enclosing application code should be aware that data that it expecting ain't
> coming. Here is the example of the unsuccessful translation of the SQLJ
> object that is coming from the DB and is supposed to be translated into the
> normal java bean. Translation fails due to SQLException, but application
> code is not getting any indication of it.
> 
> Question: Is there the way to switch this behavior off or limit it to
> certain kinds of exceptions?

AFAIK not at the moment but this should be possible to add this
functionality without too much knowledge of the code. managing the
difficult JCL 1.1 release is taking most of my time ATM so not sure when
i'd find time to code this.

anyone want to volunteer to create a patch?

(i'd be glad to answer questions)

- robert



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[betwixt] Exception suppression

Posted by Igor Marakov <ig...@ivmsystems.com>.
I recently ran into the situation where betwixt is suppressing exceptions
during the translation.
I don't think it is a good idea. 
Enclosing application code should be aware that data that it expecting ain't
coming. Here is the example of the unsuccessful translation of the SQLJ
object that is coming from the DB and is supposed to be translated into the
normal java bean. Translation fails due to SQLException, but application
code is not getting any indication of it.

Question: Is there the way to switch this behavior off or limit it to
certain kinds of exceptions?

Thanks,
Igor

[DEBUG] com.my.framework.dao.bc4j.TranslatorImpl (translate) : START
translation com.my.framework.model.sqlj.MenuComponentC To java.util.List

[DEBUG] com.my.framework.dao.bc4j.TranslatorImpl (toXML) : Start toXML
translation

[ERROR] org.apache.commons.betwixt.expression.MethodExpression
(handleException) : [MethodExpression] Cannot evaluate expression 

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)

at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at
org.apache.commons.betwixt.expression.MethodExpression.evaluate(MethodExpres
sion.java:61)
at
org.apache.commons.betwixt.expression.IteratorExpression.evaluate(IteratorEx
pression.java:53)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElementContent(Abstrac
tBeanWriter.java:924)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeElement(AbstractBeanWr
iter.java:738)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWrite
r.java:374)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.writeBean(AbstractBeanWrite
r.java:243)
at
org.apache.commons.betwixt.io.AbstractBeanWriter.write(AbstractBeanWriter.ja
va:144)
at org.apache.commons.betwixt.io.BeanWriter.write(BeanWriter.java:190)
at com.my.framework.dao.bc4j.TranslatorImpl.toXML(TranslatorImpl.java:180)
at
com.my.framework.dao.bc4j.TranslatorImpl.translate(TranslatorImpl.java:135)
at
com.my.framework.dao.bc4j.DAOProxyInvocationHandler.invoke(DAOProxyInvocatio
nHandler.java:117)
at $Proxy0.getMenuComponents(Unknown Source)
at com.my.framework.dao.TestDAO_1.doMenuTest(TestDAO_1.java:125)
at com.my.framework.dao.TestDAO_1.doTests(TestDAO_1.java:73)
at com.my.framework.dao.TestDAO_1.main(TestDAO_1.java:54)

Caused by: java.sql.SQLException: Fail to construct descriptor: Invalid
arguments
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:155)
at oracle.sql.StructDescriptor.createDescriptor(StructDescriptor.java:130)
at oracle.jpub.runtime.MutableStruct.toDatum(MutableStruct.java:115)
at
com.my.framework.model.sqlj.MenuComponentT.toDatum(MenuComponentT.sqlj:110)
at oracle.jpub.runtime.Util._convertToOracle(Util.java:160)
at oracle.jpub.runtime.Util.convertToOracle(Util.java:146)
at oracle.jpub.runtime.MutableArray.getDatumElement(MutableArray.java:1273)
at oracle.jpub.runtime.MutableArray.getOracleArray(MutableArray.java:639)
at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:810)
at oracle.jpub.runtime.MutableArray.getObjectArray(MutableArray.java:816)
at
com.my.framework.model.sqlj.MenuComponentC.getArray(MenuComponentC.java:76)

            ... 19 more

[DEBUG] com.my.framework.dao.bc4j.TranslatorImpl (toXML) : Resulting XML
<?xml version='1.0' ?>
  <elements/>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [betwixt] Reader registration problem

Posted by Igor Marakov <ig...@ivmsystems.com>.
Hi Robert,
I use 0.7 binaries downloaded on 1/20
Changing one of the xmltags, something like "mybean" to "mibean", and
leaving the other one be, fixes the issue. 

I'll see if I can try to get latest binaries.

Thanks,
igor

-----Original Message-----
From: robert burrell donkin [mailto:robertburrelldonkin@blueyonder.co.uk] 
Sent: Wednesday, March 01, 2006 5:55 PM
To: Jakarta Commons Users List
Subject: Re: [betwixt] Reader registration problem

hi igor

are you using the latest code (from a recently nightly or subversion)?

if not, could you retry using the latest code?

if you can supply a test case (please attach it to a bugzilla)
demonstrating the issue, i'll see if i can fix it.

- robert


On Wed, 2006-03-01 at 16:40 -0500, Igor Marakov wrote:
> I wonder if anybody had seen this:
> 
> When reader registration map is created for incoming XML translation it is
> created with tag/class pairs.
> 
> I ran today into the situations when IF an element of the registration
> HashMap in the reader has NOT NULL "next" element, then during the
> translation instance of the wrong class is created. 
> 
> Unfortunately I cannot provide a real example but, here is what happens:
> 
> ** registration process **
> ...
> reader.registerBeanClass("mybean", com.rather.long.class.name.Mybean);
> reader.registerBeanClass("mybeanSimilarName",
> com.rather.long.class.name.MybeanSimilarName);
> ...
> 
> What I see in debugger:
> ** resulting HashMap ** inside the reader ( registeredClasses )
> HashMap$Entry [xx] value com.rather.long.class.name.Mybean
> Field "key"  com.rather.long.class.name.Mybean
> Field "next" HashMap$Entry com.rather.long.class.name.MybeanSimilarName
> 
> 
> ** On translation of the XML element "mybeanSimilarName"
> 
> ** Bean factory ( I have my own chained in ) ** 
> reports two beans being instantiated:
> com.rather.long.class.name.Mybean
> com.rather.long.class.name.MybeanSimilarName
> 
> 
> ** resulting object is **
> com.rather.long.class.name.Mybean
>  
> 
> Thanks,
> Igor
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [betwixt] Reader registration problem

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi igor

are you using the latest code (from a recently nightly or subversion)?

if not, could you retry using the latest code?

if you can supply a test case (please attach it to a bugzilla)
demonstrating the issue, i'll see if i can fix it.

- robert


On Wed, 2006-03-01 at 16:40 -0500, Igor Marakov wrote:
> I wonder if anybody had seen this:
> 
> When reader registration map is created for incoming XML translation it is
> created with tag/class pairs.
> 
> I ran today into the situations when IF an element of the registration
> HashMap in the reader has NOT NULL "next" element, then during the
> translation instance of the wrong class is created. 
> 
> Unfortunately I cannot provide a real example but, here is what happens:
> 
> ** registration process **
> ...
> reader.registerBeanClass("mybean", com.rather.long.class.name.Mybean);
> reader.registerBeanClass("mybeanSimilarName",
> com.rather.long.class.name.MybeanSimilarName);
> ...
> 
> What I see in debugger:
> ** resulting HashMap ** inside the reader ( registeredClasses )
> HashMap$Entry [xx] value com.rather.long.class.name.Mybean
> Field "key"  com.rather.long.class.name.Mybean
> Field "next" HashMap$Entry com.rather.long.class.name.MybeanSimilarName
> 
> 
> ** On translation of the XML element "mybeanSimilarName"
> 
> ** Bean factory ( I have my own chained in ) ** 
> reports two beans being instantiated:
> com.rather.long.class.name.Mybean
> com.rather.long.class.name.MybeanSimilarName
> 
> 
> ** resulting object is **
> com.rather.long.class.name.Mybean
>  
> 
> Thanks,
> Igor
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[betwixt] Reader registration problem

Posted by Igor Marakov <ig...@ivmsystems.com>.
I wonder if anybody had seen this:

When reader registration map is created for incoming XML translation it is
created with tag/class pairs.

I ran today into the situations when IF an element of the registration
HashMap in the reader has NOT NULL "next" element, then during the
translation instance of the wrong class is created. 

Unfortunately I cannot provide a real example but, here is what happens:

** registration process **
...
reader.registerBeanClass("mybean", com.rather.long.class.name.Mybean);
reader.registerBeanClass("mybeanSimilarName",
com.rather.long.class.name.MybeanSimilarName);
...

What I see in debugger:
** resulting HashMap ** inside the reader ( registeredClasses )
HashMap$Entry [xx] value com.rather.long.class.name.Mybean
Field "key"  com.rather.long.class.name.Mybean
Field "next" HashMap$Entry com.rather.long.class.name.MybeanSimilarName


** On translation of the XML element "mybeanSimilarName"

** Bean factory ( I have my own chained in ) ** 
reports two beans being instantiated:
com.rather.long.class.name.Mybean
com.rather.long.class.name.MybeanSimilarName


** resulting object is **
com.rather.long.class.name.Mybean
 

Thanks,
Igor


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [betwixt] unable to read XML into collection. Please help

Posted by Igor Marakov <ig...@ivmsystems.com>.
Many thanks to all the people who offered suggestions.

Those helped a lot to straighten out configuration problems. 
Funny thing - code truly started working only after I split single
betwixt-config file into individual dotbetwixt files. 
Weird. I am not even sure I can formulate problem correctly to post it on
developers list. Something to do with preloaded and cached configuration.

Thanks again.
Igor

-----Original Message-----
From: Mornak [mailto:dmornacco@gmail.com] 
Sent: Wednesday, February 08, 2006 8:46 AM
To: Jakarta Commons Users List
Subject: Re: [betwixt] unable to read XML into collection. Please help

Try this

<?xml version="1.0" encoding="UTF-8"?>
<betwixt-config>
  <class name='com.my.CollectionWrapper' >
   <element name='elements'>
     <element property='elements' updater='addElement'/>
   </element>
  </class>

notice that i changed 2 things:
- the name of the property is elementS (plural), not element
- I added an updater to specify the method that betwixt should invoke
(it may be not necesary)


I hope to be helpfull

PS: Excuse my terrible english. I am not an english native speaker



On 2/7/06, Igor Marakov <ig...@ivmsystems.com> wrote:
> Hi,
>
> I have a simple (or so it seems) problem.
> There is a piece of XML that represents a list of items.
> I need to convert this XML to the List of beans.
> I must be doing something very wrong but for couple days now I am not able
> to come up with combination of code and configuration that would work. I
can
> see beans being created but assignment into List never happens. At the
same
> time running single beans does work.
> Obviously I'm missing something big time here;
> Any help will be greatly appreciated.
> Relevant code pieces and configuration is below.
>
> Thanks,
> Igor
>
> ****  SETUP  ( done once in translator life cycle )
>
> // insert my bean factory, verified - works, beans created ok.
> beanCreationChain = BeanCreationList.createStandardChain();
> beanCreationChain.insertBeanCreator(1, new BeanCreator() );
>
> // load betwixt-config, save XMLIntrospector for future use
> BeanWriter writer = new BeanWriter();
> introspector = writer.getXMLIntrospector();
> InputSource is = new
> InputSource(TranslatorImpl.class.getResourceAsStream(translatorConfig));
>
> introspector.register(is);
> introspector.getConfiguration().setWrapCollectionsInElement(true);
> writer.getBindingConfiguration().setMapIDs(false);
>
> // save Configuration for future use
> configuration = writer.getBindingConfiguration();
>
>
>
> **** BETWIXT CONFIG  ( loaded by above code )
>
> <?xml version="1.0" encoding="UTF-8"?>
> <betwixt-config>
>    <class name='com.my.CollectionWrapper' >
>     <element name='elements'>
>       <element property='element' />
>     </element>
>    </class>
>
>    <class name='com.my.Application'>
>      <element name='application'>
>        <attribute name='id' property='id'/>
>        <attribute name='name' property='name' />
>        <element name='description' property='description' />
>        <addDefaults add-properties='false'/>
>      </element>
>    </class>
> </betwixt-config>
>
>
> **** XML IN  ( to be loaded into collection )
>
> <?xml version='1.0' ?>
>   <elements>
>     <application id="2" name="bean2">
>       <description>Application Bean 2</description>
>     </application>
>     <application id="3" name="bean3">
>       <description>Application Bean 3</description>
>     </application>
>     <application id="1" name="bean1">
>       <description> Application Bean 1</description>
>     </application>
>   </elements>
>
>
> **** READING  ( actual translation step )
>
>  Object result = null;
>  StringReader xmlReader = new StringReader(buffer);  // XML IN
>
>  BeanReader reader  = new BeanReader();
>
> // using configuration saved earlier
>  reader.setXMLIntrospector(introspector);
>  reader.setBindingConfiguration(configuration);
>  reader.getReadConfiguration().setBeanCreationChain(beanCreationChain);
>
>  reader.registerBeanClass("elements",
> Class.forName("com.my.CollectionWrapper"));
>
>  reader.registerBeanClass("application",
> Class.forName("com.my.Application"));
>
>  result = reader.parse(xmlReader);
>
> //  RESULT Contains empty collection.
> //  Adding to collection in CollectionWrapper never happens
>
>
> **** COLLECTION WRAPPER
>
> public class CollectionWrapper
> {
>   private static Logger log = Logger.getLogger(CollectionWrapper.class);
>   private Collection elements = null;
>   public CollectionWrapper()
>   {
>     log.debug("*********  CONSTRUCTOR  ******************");
>     elements = new java.util.ArrayList();
>   }
>
>   public void addElement(Object element)
>   {
>     log.debug("**********  ADD  *************** " + element.toString());
>     elements.add(element);
>   }
>
>   public Collection getElementCollection() { return elements; }
>
>   public Iterator getElements() { return elements.iterator(); }
>
>   public void setElements(Collection elements) { this.elements = elements;
}
>
>
>
> // this did not work either
>
> //  public Collection getApplications(Application element) {
> addElement(element); }
>
> //  public void addApplication(Application element) { addElement(element);
}
>
>
> //  public void setApplication(Application element) { addElement(element);
}
>
>
>
>
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


--

To Iterate is Human, to Recurse, Divine
 - James O. Coplien, Bell Labs

-------------------------------------
<EPI/> - Deploying ideas
-------------------------------------
Ing. Diego H. Mornacco
Desarrollador
Epidata Consulting
MaipĂș 521 1er piso Of. A
Ofi: 5031 0060 / 61
Cel: 15-5884-0040
www.epidataconsulting.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [betwixt] unable to read XML into collection. Please help

Posted by Mornak <dm...@gmail.com>.
Try this

<?xml version="1.0" encoding="UTF-8"?>
<betwixt-config>
  <class name='com.my.CollectionWrapper' >
   <element name='elements'>
     <element property='elements' updater='addElement'/>
   </element>
  </class>

notice that i changed 2 things:
- the name of the property is elementS (plural), not element
- I added an updater to specify the method that betwixt should invoke
(it may be not necesary)


I hope to be helpfull

PS: Excuse my terrible english. I am not an english native speaker



On 2/7/06, Igor Marakov <ig...@ivmsystems.com> wrote:
> Hi,
>
> I have a simple (or so it seems) problem.
> There is a piece of XML that represents a list of items.
> I need to convert this XML to the List of beans.
> I must be doing something very wrong but for couple days now I am not able
> to come up with combination of code and configuration that would work. I can
> see beans being created but assignment into List never happens. At the same
> time running single beans does work.
> Obviously I'm missing something big time here;
> Any help will be greatly appreciated.
> Relevant code pieces and configuration is below.
>
> Thanks,
> Igor
>
> ****  SETUP  ( done once in translator life cycle )
>
> // insert my bean factory, verified - works, beans created ok.
> beanCreationChain = BeanCreationList.createStandardChain();
> beanCreationChain.insertBeanCreator(1, new BeanCreator() );
>
> // load betwixt-config, save XMLIntrospector for future use
> BeanWriter writer = new BeanWriter();
> introspector = writer.getXMLIntrospector();
> InputSource is = new
> InputSource(TranslatorImpl.class.getResourceAsStream(translatorConfig));
>
> introspector.register(is);
> introspector.getConfiguration().setWrapCollectionsInElement(true);
> writer.getBindingConfiguration().setMapIDs(false);
>
> // save Configuration for future use
> configuration = writer.getBindingConfiguration();
>
>
>
> **** BETWIXT CONFIG  ( loaded by above code )
>
> <?xml version="1.0" encoding="UTF-8"?>
> <betwixt-config>
>    <class name='com.my.CollectionWrapper' >
>     <element name='elements'>
>       <element property='element' />
>     </element>
>    </class>
>
>    <class name='com.my.Application'>
>      <element name='application'>
>        <attribute name='id' property='id'/>
>        <attribute name='name' property='name' />
>        <element name='description' property='description' />
>        <addDefaults add-properties='false'/>
>      </element>
>    </class>
> </betwixt-config>
>
>
> **** XML IN  ( to be loaded into collection )
>
> <?xml version='1.0' ?>
>   <elements>
>     <application id="2" name="bean2">
>       <description>Application Bean 2</description>
>     </application>
>     <application id="3" name="bean3">
>       <description>Application Bean 3</description>
>     </application>
>     <application id="1" name="bean1">
>       <description> Application Bean 1</description>
>     </application>
>   </elements>
>
>
> **** READING  ( actual translation step )
>
>  Object result = null;
>  StringReader xmlReader = new StringReader(buffer);  // XML IN
>
>  BeanReader reader  = new BeanReader();
>
> // using configuration saved earlier
>  reader.setXMLIntrospector(introspector);
>  reader.setBindingConfiguration(configuration);
>  reader.getReadConfiguration().setBeanCreationChain(beanCreationChain);
>
>  reader.registerBeanClass("elements",
> Class.forName("com.my.CollectionWrapper"));
>
>  reader.registerBeanClass("application",
> Class.forName("com.my.Application"));
>
>  result = reader.parse(xmlReader);
>
> //  RESULT Contains empty collection.
> //  Adding to collection in CollectionWrapper never happens
>
>
> **** COLLECTION WRAPPER
>
> public class CollectionWrapper
> {
>   private static Logger log = Logger.getLogger(CollectionWrapper.class);
>   private Collection elements = null;
>   public CollectionWrapper()
>   {
>     log.debug("*********  CONSTRUCTOR  ******************");
>     elements = new java.util.ArrayList();
>   }
>
>   public void addElement(Object element)
>   {
>     log.debug("**********  ADD  *************** " + element.toString());
>     elements.add(element);
>   }
>
>   public Collection getElementCollection() { return elements; }
>
>   public Iterator getElements() { return elements.iterator(); }
>
>   public void setElements(Collection elements) { this.elements = elements; }
>
>
>
> // this did not work either
>
> //  public Collection getApplications(Application element) {
> addElement(element); }
>
> //  public void addApplication(Application element) { addElement(element); }
>
>
> //  public void setApplication(Application element) { addElement(element); }
>
>
>
>
> }
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>


--

To Iterate is Human, to Recurse, Divine
 - James O. Coplien, Bell Labs

-------------------------------------
<EPI/> - Deploying ideas
-------------------------------------
Ing. Diego H. Mornacco
Desarrollador
Epidata Consulting
MaipĂș 521 1er piso Of. A
Ofi: 5031 0060 / 61
Cel: 15-5884-0040
www.epidataconsulting.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[betwixt] unable to read XML into collection. Please help

Posted by Igor Marakov <ig...@ivmsystems.com>.
Hi,

I have a simple (or so it seems) problem. 
There is a piece of XML that represents a list of items. 
I need to convert this XML to the List of beans.
I must be doing something very wrong but for couple days now I am not able
to come up with combination of code and configuration that would work. I can
see beans being created but assignment into List never happens. At the same
time running single beans does work.
Obviously I'm missing something big time here; 
Any help will be greatly appreciated.
Relevant code pieces and configuration is below.

Thanks,
Igor

****  SETUP  ( done once in translator life cycle )

// insert my bean factory, verified - works, beans created ok.
beanCreationChain = BeanCreationList.createStandardChain();
beanCreationChain.insertBeanCreator(1, new BeanCreator() ); 

// load betwixt-config, save XMLIntrospector for future use
BeanWriter writer = new BeanWriter();
introspector = writer.getXMLIntrospector();
InputSource is = new
InputSource(TranslatorImpl.class.getResourceAsStream(translatorConfig));

introspector.register(is);
introspector.getConfiguration().setWrapCollectionsInElement(true);
writer.getBindingConfiguration().setMapIDs(false);

// save Configuration for future use
configuration = writer.getBindingConfiguration();   

 

**** BETWIXT CONFIG  ( loaded by above code )

<?xml version="1.0" encoding="UTF-8"?>
<betwixt-config>
   <class name='com.my.CollectionWrapper' >     
    <element name='elements'>
      <element property='element' />
    </element>  
   </class>   
 
   <class name='com.my.Application'>
     <element name='application'>
       <attribute name='id' property='id'/>
       <attribute name='name' property='name' />
       <element name='description' property='description' />       
       <addDefaults add-properties='false'/>
     </element>
   </class>
</betwixt-config>
 

**** XML IN  ( to be loaded into collection )

<?xml version='1.0' ?>
  <elements>
    <application id="2" name="bean2">
      <description>Application Bean 2</description>
    </application>
    <application id="3" name="bean3">
      <description>Application Bean 3</description>
    </application>
    <application id="1" name="bean1">
      <description> Application Bean 1</description>
    </application>
  </elements>
 

**** READING  ( actual translation step )

 Object result = null;
 StringReader xmlReader = new StringReader(buffer);  // XML IN

 BeanReader reader  = new BeanReader();

// using configuration saved earlier 
 reader.setXMLIntrospector(introspector);              
 reader.setBindingConfiguration(configuration);
 reader.getReadConfiguration().setBeanCreationChain(beanCreationChain);

 reader.registerBeanClass("elements",
Class.forName("com.my.CollectionWrapper")); 

 reader.registerBeanClass("application",
Class.forName("com.my.Application"));    

 result = reader.parse(xmlReader);
	 
//  RESULT Contains empty collection. 
//  Adding to collection in CollectionWrapper never happens
 

**** COLLECTION WRAPPER

public class CollectionWrapper
{
  private static Logger log = Logger.getLogger(CollectionWrapper.class);
  private Collection elements = null;
  public CollectionWrapper()
  {
    log.debug("*********  CONSTRUCTOR  ******************");
    elements = new java.util.ArrayList();      
  }

  public void addElement(Object element) 
  { 
    log.debug("**********  ADD  *************** " + element.toString());
    elements.add(element); 
  }
  
  public Collection getElementCollection() { return elements; }
 
  public Iterator getElements() { return elements.iterator(); }
 
  public void setElements(Collection elements) { this.elements = elements; }

 

// this did not work either 

//  public Collection getApplications(Application element) {
addElement(element); }

//  public void addApplication(Application element) { addElement(element); }


//  public void setApplication(Application element) { addElement(element); }


 

}





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


[validator] using submitted form value with validator

Posted by "Afshartous, Nick" <Ni...@WorkStreamInc.com>.
Hi,

I was wondering how to pass a submitted form value to be used as part of a validator error message.

For instance, for the message

    errors.email={0} is an invalid e-mail address.

how would one specify in validation.xml that the submitted form field value would fill in the {0} argument.

Thanks.

      Nick


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org