I did, but I apparently used a much more recent version of ModalBox. The version you are using is very, very old. They changed the "onContentLoaded" callback to "afterLoad" so the form scripts weren't being called.

However, there are several other issues with the code you mentioned.

1. Form error handling doesn't work because the dialog doesn't resize. (Later versions of ModalBox have a resizeToContent method.) Using my modified version of your script, I can get resize working if I put in an inline script.

2. Also, if you hit cancel, the form is inserted into the DOM and you see it in on your page.

3. There doesn't appear to be a way to submit and close only if there were no errors.

4. Using a t:submit with mode="CANCEL" doesn't work, It submits anyway.

Norman Franke
Answering Service for Directors, Inc.
www.myasd.com



On Jul 7, 2011, at 9:22 PM, Taha Hafeez wrote:

Hi

Have you tried the modaldialog at
https://github.com/tawus/tawus/tree/master/tawus-addons

Here is an example

public class ModalDialogWithForm
{
  @Property
  @Persist(PersistenceConstants.FLASH)
  private String name;

  @Property
  @Persist(PersistenceConstants.FLASH)
  private String address;

  @Inject
  private Block formBlock;

  @InjectComponent
  private Zone zone;

  @SuppressWarnings("unused")
  @Property
  private String message;

  void onSuccess()
  {
     message = String.format("Hello %s, your address is %s", name,
address);
  }

  void onFailure()
  {
     message = String.format("Submission failed");
  }

  Object onSubmit()
  {
     return zone;
  }

  Block onShowDialog()
  {
     return formBlock;
  }
}

<html xmlns:t='http://tapestry.apache.org/schema/tapestry_5_1_0.xsd'>
  <body>
     <a t:type='tawus/modaldialog'>Show Dialog with form</a>

     <t:block t:id='formBlock'>
        <div t:type='zone' t:id='zone' id='zone'>
           <div
style='font-size:12px;font-weight:bold;color:green'>${message}</div>
           <form t:type='form' t:zone='zone'>
              <t:errors />
              <label t:type='label' for='name'>Name :
                 <input t:type='textfield' t:id='name'
t:validate='required'/>
              </label>
              <br />

              <label t:type='label' for='address'>Address:
                 <textarea t:type='textarea' t:id='address'
t:validate='required'></textarea>
              </label>

               <br/>
              <input type='submit' value='Submit' />
           </form>
        </div>
     </t:block>

  </body>
</html>

regards
Taha


On Fri, Jul 8, 2011 at 2:56 AM, Norman Franke <fra...@bethzur.com> wrote:

I'm attempting to display a ModalBox dialog with a form in it and submit that form via AJAX. I've tried a few components people have posted to the list. The display of the form works great, but Tapestry refuses to make it
submit via AJAX.

I want to do this so I can display validation errors in the dialog, which
are otherwise ignored.

Has anyone got this to work with Tapestry 5.2.5?

-Norman


------------------------------**------------------------------ **--------- To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org >
For additional commands, e-mail: users-h...@tapestry.apache.org




--
regards
Tawus
tawus.wordpress.com

Reply via email to