You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mike Zatko <mz...@boscovs.com> on 2004/08/12 16:13:38 UTC

[Digester] Mapping with primatives

I have a problem where I need digester to map to primitive values. I 
have a bean that has properties with setters as such:

setDiscountTotal(double discountTotal);

Digester won't match to it and I can't find out what to do. Any suggestions?

> 171 [main] DEBUG org.apache.commons.digester.Digester  -   
> match='com.boscovs.translator.dto.sql.Order/discount-total'
> 171 [main] DEBUG org.apache.commons.digester.Digester  -   bodyText='0.0'
> 171 [main] DEBUG org.apache.commons.digester.Digester  -   Fire body() 
> for CallMethodRule[methodName=setDiscountTotal, paramCount=0, 
> paramTypes={java.lang.String}]
> 171 [main] DEBUG org.apache.commons.digester.Digester  -   Popping 
> body text ''
> 171 [main] DEBUG org.apache.commons.digester.Digester  -   Fire end() 
> for CallMethodRule[methodName=setDiscountTotal, paramCount=0, 
> paramTypes={java.lang.String}]
> 171 [main] DEBUG org.apache.commons.digester.Digester  - 
> [CallMethodRule]{com.boscovs.translator.dto.sql.Order/discount-total} 
> Call 
> com.boscovs.translator.dto.sql.Order.setDiscountTotal(0.0/java.lang.String)
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - Matching 
> name=setDiscountTotal on class com.boscovs.translator.dto.sql.Order
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - Found 
> matching name:
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - public 
> void com.boscovs.translator.dto.sql.Order.setDiscountTotal(double)
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - 
> Param=java.lang.String
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - Method=double
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - double is 
> not assignable from class java.lang.String
> 171 [main] DEBUG org.apache.commons.beanutils.MethodUtils  - No match 
> found.
> 171 [main] ERROR org.apache.commons.digester.Digester  - End event 
> threw exception
> java.lang.NoSuchMethodException: No such accessible method: 
> setDiscountTotal() on object: com.boscovs.translator.dto.sql.Order


-- 
Michael H. Zatko
Java Enterprise Developer
Boscov's Information Services
Work: 610-929-7317
Home: 610-376-1624
Page: 610-736-4460



Re: [Digester] Mapping with primatives

Posted by Craig McClanahan <cr...@gmail.com>.
On Thu, 12 Aug 2004 10:13:38 -0400, Mike Zatko <mz...@boscovs.com> wrote:
> I have a problem where I need digester to map to primitive values. I
> have a bean that has properties with setters as such:
> 
> setDiscountTotal(double discountTotal);
> 
> Digester won't match to it and I can't find out what to do. Any suggestions?
> 

You don't show the code you're using to initialize the rules, but the
log implies that you are configuring your CallNextRule instances
without telling Digester what data type to use.  In such a scenario,
Digester assumes that the argument is a String.

Try something like this:

  digester.addCallMethod("...", "setDiscountTotal", 1,
    new String[] { "java.lang.Double" });

Craig

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