Hello Everyone

It's about 12 months since I used Tapestry but its good to be back :-) I'm
currently writing an Ajax based order form for a client but I've hit a
little problem. Basically I have a series of blocks which are used to
represent 'pages' in the order form i.e. I have a block for product
selection one for shipping address etc. As the user moves through the
checkout process the different blocks are rendered inside a zone:

Order.java:

@Component(parameters={"value=order.techFirstName"})
@Property
private TextField techFirstName;

@Component(parameters={"value=order.billingFirstName"})
@Property
private TextField bilingFirstName;

@Inject
private Block productSelection;
@Inject
private Block userDetails;

Object onSuccess() {
 ...
return new MultiZoneUpdate("orderForm", userDetails);
}

Order.tml:

<t:zone tid="orderForm">
  <t:delegate to="productSelection" />
</t:zone>

<t:block t:id="userDetails">
 <t:form>
    <t:textField t:id="techFirstName" />
    <t:textField t:id="billingFirstName" />
    ...
</t:form>
</t:block>

This is all working nicely but I now need to get the clientId of the
techFirstName element which in rendered inside the userDetails block. I'm
looking to perform a client side copy of the techFirstName element to
another form element within the block. My question is where do I put the
call to ${techFirstName.clientId} ? If I create a javascript function
outside the block getClientId returns null because the block hasn't yet been
rendered. If I put the javascript function inside the block it doesn't get
called. i.e. this doesn't work:

<t:block t:id="userDetails">
  <t:form>
    <t:textField t:id="techFirstName" />
    <t:textField t:id="billingFirstName" />
    <input type="checkbox" onclick="copyDetails()" />

    <script type="text/javascript">
      function copyDetails() {
        var techFirstNameElementId = '${techFirstName.clientId}';
       ...
     }
    </script>
  </t:form>
</t:block>

when i check the box i get an error because copyDetails() isn't defined

Does anyone know what is the best way to get a clientId for an element which
is rendered via Ajax?

Many Thanks

Toby

Reply via email to