You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Peter Pilgrim <pe...@db.com> on 2002/04/05 11:47:12 UTC

Re: RequestUtils.populate ( BeanUtils.populate) [SOLVED]


My problem is that I had a convenience function in the action form

    public void setCashflowLimit( UserCashflowLimit limit )
    {
      System.out.println( "AACF.setCashflowLimit("+ccyCode+", "+limit+")");
      mapLimits.put( limit.getCcyCode(), limit );
    }

My `UserCashflowLimit' bean also has a "ccyCode" attribute. So I added
the convenience method in the "Action" controller. Once I remove
this convenience method above and recode the long form. Everything
started wrong and the form suddenly populates the nested cashflow limits
beans.

I think the Java Beans Introspector blew up trying to figure out the correct "write" method.

DAMN!

This is is confusing. There must be an easier way to debug this, apart attacking the problem
from lots of "<bean:write>" tags.

For future reference mapped properties have the form

         public    {XYZ}     get{AttributeName}( String key ) {  .... }

         public    void        set{ AttributeName}( String key,   {XYZ} value ) {  .... }

--
Peter Pilgrim                       ++44 (0)207-545-9923

............................................ Swamped under electronic mails


---------------------------------------- Message History ----------------------------------------


From:  Peter Pilgrim/DMGIT/DMG UK/DeuBa@DMG UK on 05/04/2002 10:16 CET

Please respond to "Struts Users Mailing List" <st...@jakarta.apache.org>

To:    "Struts Users Mailing List" <st...@jakarta.apache.org>
cc:
Subject:    Re: RequestUtils.populate ( BeanUtils.populate)




Hi

This is the real deal this time. This is the real code extract
instead of something made up.

==================

public class AccountAdminControllerForm extends ActionForm ...
{
    /** Map of currency codes to user cashflow limit objects */
    private Map         mapLimits = new TreeMap();

    public UserCashflowLimit getCashflowLimit( String ccyCode )
    {
      System.out.println( "AACF.getCashflowLimit("+ccyCode+")");
      return (UserCashflowLimit) mapLimits.get( ccyCode );
    }

    public void setCashflowLimit( String ccyCode, UserCashflowLimit limit )
    {
      System.out.println( "AACF.setCashflowLimit("+ccyCode+", "+limit+")");
      mapLimits.put( ccyCode, limit );
    }

    ...
}


public class UserCashflowLimit {

    private BigDecimal  cashflowAmount=null;
    private String      amountText = null;

    public BigDecimal getCashflowAmount()
    {        return cashflowAmount;  }

    public void setCashflowAmount( BigDecimal cashflowAmount )
    {        this.cashflowAmount = cashflowAmount;  }

    public String getAmount()
    {        return amountText  }

    public void setAmount( String amountText )
    {
        System.out.println( "UCL.setAmount("+amountText+")" );
        this.amountText = StringUtil.notNull(amountText);
    }

    ...
}


Here is the real JSP code



<html:form action="/AccountAdminController.do" method="POST" >

...

<html:text property="cashflowLimit(USD).amountText" >
   <bean:write name="accountAdminControllerForm"
               property="cashflowLimit(USD).cashflowAmount" />
</html:text>

...

</html:form>

==================

I am still have problems with the actual signature. This is what the Javadoc for
`PropertyUtils' has to say

 * <li><strong>Mapped (<code>name(key)</code>)</strong> - The JavaBean
 *     is assumed to have an property getter and setter methods with an
 *     additional attribute of type <code>java.lang.String</code>.</li>

Does this mean the `PropertyUtils' only supports property values that are
`java.lang.String' types?

public String getSomeAttribute( String key )
pubic void setSomeAttribute( String key, String values )

I know the property key have to be `java.lang.String' ?

--
Peter Pilgrim                       ++44 (0)207-545-9923

............................................ Swamped under electronic mails


--<CUT>--


--

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>