Announcement Announcement Module
Collapse
No announcement yet.
Custom Property Editor for form field with variable name? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom Property Editor for form field with variable name?

    Hi all,

    I'm trying to register a custom property editor in my controller for a .jsp text input field with a name attribute that changes... and I'm having trouble writing the binder.registerCustomEditor() statement:



    These code samples should help explain:

    My .jsp:
    Code:
    	<c&#58;forEach var="buyerSeller" items="$&#123;BlockTrade.buyerSellers&#125;" varStatus="status">
     		Broker&#58; <input type="text" name="buyerSellers&#91;<c&#58;out value="$&#123;status.index&#125;"/>&#93;.broker" value="some value" /></br>
                    </p>
    	</c&#58;forEach>
    Essentially the field name changes based on the index and becomes
    buyerSellers[0].broker,
    buyerSellers[1].broker,
    buyerSellers[2].broker,
    etc.,
    etc.

    The only binder.registerCustomEditor() statement I have gotten to work is as following:

    Code:
    		binder.registerCustomEditor&#40;Broker.class, "buyerSellers&#91;0&#93;.broker", customBrokerEditor&#41;;
    		binder.registerCustomEditor&#40;Broker.class, "buyerSellers&#91;1&#93;.broker", customBrokerEditor&#41;;
    etc.
    etc.
    etc.
    Is there a way to register the custom property editor to the field in a single statement?

  • #2
    If all Broker.class fields are handled the same way you can try:
    Code:
    binder.registerCustomEditor&#40;Broker.class, customBrokerEditor&#41;;

    Comment


    • #3
      that worked great, thanks

      Comment

      Working...
      X