The dojo dialog control moves the rendered dialog around in the DOM so it's just inside the closing </body> tag. They do this so it's in a known place and they can make some assumptions about (lack of) nesting when it renders. However, this effectively moves it outside any forms. Use firebug to inspect the DOM when you show the dialog and you'll see it at the very end instead of where you placed it. To make things work, you have to place the dojo dialog outside any existing forms and it needs to include it's own @Form tag. Alternately, I made a dirty hack to move the dialog just inside a closing form tag instead of a body tag. It works for me because my <form> is just inside <body>, but I don't know how well it'll work on other structures.

FormDialog.java:
package com.vms.infrastructure.tapestry.components;

import java.util.HashMap;
import java.util.Map;

import org.apache.tapestry.IForm;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.IScript;
import org.apache.tapestry.TapestryUtils;
import org.apache.tapestry.annotations.ComponentClass;
import org.apache.tapestry.annotations.InjectScript;
import org.apache.tapestry.annotations.Parameter;
import org.apache.tapestry.dojo.html.Dialog;

@ComponentClass(allowBody=true, allowInformalParameters=true)
public abstract class FormDialog extends Dialog {
@Parameter(defaultValue="ognl:true")
   public abstract boolean isHidden();
@Parameter(defaultValue="literal:black")
   public abstract String getBackgroundColor();
@Parameter(defaultValue="0.4")
   public abstract float getOpacity();
@Parameter
   public abstract String getParent();
@InjectScript("FormNest.script")
   public abstract IScript getMoveScript();

   @InjectScript("Dialog.script")
   public abstract IScript getScript();

   public void renderComponent(IMarkupWriter writer, IRequestCycle cycle) {
       super.renderComponent(writer, cycle);
       if (cycle.isRewinding()) {
           return;
       }
       // don't need this during rewind
       String resolvedParent = null;
       if (isParameterBound("parent")) {
           resolvedParent = getParent();
       } else {
IForm form = (IForm) cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE);
           if (form != null) {
               resolvedParent = form.getClientId();
           }
       }
       if (resolvedParent != null) {
           Map<String,Object> symbols = new HashMap<String,Object>();
           symbols.put("dialogId", getClientId());
           symbols.put("parent", resolvedParent);
getMoveScript().execute(this, cycle, TapestryUtils.getPageRenderSupport(cycle, this), symbols);
       }
   }
}

FormNest.script:
<?xml version="1.0"?>
<!DOCTYPE script PUBLIC
 "-//Apache Software Foundation//Tapestry Script Specification 3.0//EN"
 "http://jakarta.apache.org/tapestry/dtd/Script_3_0.dtd";>

<script>

   <input-symbol key="dialogId"  class="java.lang.String" required="yes"/>
   <input-symbol key="parent"  class="java.lang.String" required="yes"/>
<initialization>
       dojo.byId('${parent}').appendChild(dojo.byId('${dialogId}'))
   </initialization>

</script>

I also had to copy Dialog.script into my scripts folder.

-Steve

Paul Stanton wrote:
Fair enough, it was a pretty jumbled structure and as a result difficult to describe. Unfortunately I've moved on with my form separation method (as you describe how you use dialog forms) which works well enough.

Essentially I had

<form>
   <some form elements/>
   <link onclick="async:load data into dialog and show it"/>
   <submit onclick="sync:save form, dialog portion blank and ignored"/>
   <dialog hidden="true">
      <some form elements/>
<submit onclick="sync:save whole form including dialog part and reload page"/>
   </dialog>
</form>

Now, when I used the dialog submit the dialog's form elements were submitting null/empty values. My theory was that when the dialog and child components were re-rendered when the dialog was updated in the async request, they were becoming detached form the original form.

Come to think of it, I wasn't specifying the component Id's (ie i was just doing jwcid="@TextField") maybe if I specified an Id it would work?

Thanks for the interest jesse. does any of this make sense?

Jesse Kuhnert wrote:
I can't really piece together what you are doing vs. what is not working as expected but the Dialog component essentially does nothing other than wrap a
block of html.

Tapestry does maintain form state during ajax requests - so if that's not
happening then something is wrong.  It's possible that the client side
javascript code implementing the dialog moves the html nodes around in such a way that if you don't have a form within the dialog itself that the nodes will become separated from the original form and start to break things. I have always placed forms within my dialogs even when on pages with "one big
form" as the placement of the dialog outside of the big form makes no
difference as the html displayed is always centered anyways.

Maybe an example would help but I just am not getting it looking at the
paragraphs of text.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to