Hello Peter and everybody !
I'm using tapestry 4.0, jdk 1.5 and tomcat 5.5.
I'm doing more or less the same as all of you, but I have a question.
My dojo dialogs are though to be places where the user can write information
and send it back to the server: like a way to have forms that sends
information to the server. My problem now is that all these dojo dialogs
needs a form in the same div because otherwise the submit buttons in the
dojo doesn't do anything. I understand that these dojo dialogs are rewritten
in any other place (in the DOM structure) and that's the problem why the
submit button doesn't work.
Well I have some of these popups working for list of elements, which are
modified with a dojo dialog. When I tried to save the current element (I'm
using a tag-selected of a submit button, as explained down) I always get the
last element as the modified one... Any of you have had this problem with
multiple forms ? Because is a problem of having multiple forms in a page,
because just with one form it works (but i can't have just one form due the
dojo dialog).
The way I tried to select the current element is very simple (and works with
a single form in a page, but not with a multiple form in a page):
HTML
<span jwcid="loop">
<div jwcid="dojoDialog">
<form jwcid="innerForm">
<input type="text" jwcid="name"/>
<input type="submit" jwcid="submitButton"/>
</form>
</div>
</span>
PAGE
<component id="loop" type="Form">
<binding name="source" value="elementList"/>
<binding name="value" value="currentElement"/>
</component>
<component id="personDetails" type="DojoDialogContainer"/>
<component id="innerForm" type="Form"/>
<component id="name" type="TextField">
<binding name="value" value="currentElement.name"/>
</component>
<component id="submitButton" type="Submit">
<binding name="selected" value="selectedElement"/>
<binding name="tag" value="currentElement"/>
<binding name="action" value="listener:onSubmit"/>
</component>
In the java code I get the "selectedElement" always as the last element from
the elementList but always with the correct values.
Any explanation, help, idea or something will be really appreciated,
robert
On 10/18/06, Peter Beshai <[EMAIL PROTECTED]> wrote:
Great that fixed it up :-)
You said you had wrapped the Dialog component just yesterday, but I don't
see it in the tapestry-framework trunk. Is there somewhere I can go and
see
how you implemented it?
Oh I have another question... I had to put the .jwc and .script file in
the
WEB-INF directory. It seems more standard to keep them in the same
location
as the .java file. Do I need to configure something to be able to store
everything in one place?
Anyway, here's the code I used, any suggestions are welcome!
Dialog.java::
import java.util.HashMap;
import java.util.Map;
import org.apache.tapestry.AbstractComponent;
import org.apache.tapestry.IComponent;
import org.apache.tapestry.IMarkupWriter;
import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.IScript;
import org.apache.tapestry.PageRenderSupport;
import org.apache.tapestry.TapestryUtils;
import org.apache.tapestry.dojo.DojoUtils;
import org.apache.tapestry.dojo.IWidget;
import org.apache.tapestry.json.JSONObject;
public abstract class Dialog extends AbstractComponent implements IWidget
{
/** id. */
public abstract String getIdParameter();
/** component that handles closing the dialog */
public abstract IComponent getCloser();
/** component that handles showing the dialog */
public abstract IComponent getShower();
/** bgColor */
public abstract String getBgColor();
/** bgOpacity */
public abstract Double getBgOpacity();
/** toggle */
public abstract String getToggle();
/** toggleDuration */
public abstract Integer getToggleDuration();
/** Injected script. */
public abstract IScript getScript();
public void renderWidget(IMarkupWriter writer, IRequestCycle cycle)
{
renderComponent(writer, cycle);
}
@SuppressWarnings("unchecked")
protected void renderComponent(IMarkupWriter writer, IRequestCycle
cycle)
{
if(cycle.isRewinding()) {
renderBody(writer, cycle);
return;
}
// configure the node
writer.begin("div");
writer.attribute("id", getIdParameter());
renderInformalParameters(writer, cycle);
renderBody(writer, cycle);
writer.end();
// configure the widget
JSONObject obj = DojoUtils.parseJSONParameter(this, "options");
obj.put("widgetId", getId());
obj.put("toggle", getToggle());
obj.put("toggleDuration", getToggleDuration());
obj.put("bgColor", getBgColor());
obj.put("bgOpacity", getBgOpacity());
// setup script includes
Map scriptParms = new HashMap();
scriptParms.put("id", getIdParameter());
scriptParms.put("props", obj.toString());
scriptParms.put("closer", getCloser().getId());
scriptParms.put("shower", getShower().getId());
PageRenderSupport pageRenderSupport =
TapestryUtils.getPageRenderSupport(cycle, this);
getScript().execute(this, cycle, pageRenderSupport, scriptParms);
}
}
Dialog.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="id" required="yes" />
<input-symbol key="props" required="yes" />
<input-symbol key="closer" required="yes" />
<input-symbol key="shower" required="yes" />
<body>
<unique>
dojo.require("dojo.widget.Dialog");
dojo.require("tapestry.widget.Widget");
</unique>
</body>
<initialization>
tapestry.widget.synchronizeWidgetState("${id}", "dialog",
${props});
dojo.widget.byId("${id}").setCloseControl(dojo.byId("${closer}"));
dojo.widget.byId("${id}").setShowControl(dojo.byId("${shower}"));
</initialization>
</script>
Dialog.jwc::
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://tapestry.apache.org/dtd/Tapestry_4_0.dtd">
<component-specification class="com.mycom.tapestry.Dialog"
allow-body="yes"
allow-informal-parameters="yes">
<description>
Creates a dojo dialog widget
</description>
<parameter name="closer" required="yes"/>
<parameter name="shower" required="yes"/>
<parameter name="bgColor" default-value="literal:white" />
<parameter name="bgOpacity" default-value="0.5" />
<parameter name="toggle" default-value="literal:fade"/>
<parameter name="toggleDuration" default-value="250"/>
<parameter name="id" property="idParameter" default-value="id"/>
<inject property="script" type="script" object="Dialog.script"/>
</component-specification>
Peter Beshai
>From: "Jesse Kuhnert" <[EMAIL PROTECTED]>
>Reply-To: "Tapestry users" <[email protected]>
>To: "Tapestry users" <[email protected]>
>Subject: Re: PageRenderSupport problem (Body component is in template)
>Date: Wed, 18 Oct 2006 12:31:25 -0400
>
>Without the benefit of knowing what your component code is doing I am
going
>to guess that you are attempting to render your dialog component during a
>Form "rewind" cycle.
>
>The best thing to do in your case is check for cycle.isRewinding() and
skip
>over all blocks except for renderBody() .
>
>On 10/18/06, Peter Beshai <[EMAIL PROTECTED]> wrote:
>>
>>Sorry if this idea seems silly, but this is the first custom
>>component/dojo
>>widget wrapper I have made, so it basically just does the same thing as
>>calling dojo.widget.byId("yourDlgId").show().
>>
>>My dialog takes a 'shower' and a 'closer' (IComponents) as required
>>parameters -- I wasn't sure the best way to do this... but I thought it
>>would allow more flexibility by doing it this way.
>>
>>My script looks like this: (Dialog.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="id" required="yes" />
>><input-symbol key="props" required="yes" />
>><input-symbol key="closer" required="yes" />
>><input-symbol key="shower" required="yes" />
>> <body>
>> <unique>
>> dojo.require("dojo.widget.Dialog");
>> dojo.require("tapestry.widget.Widget");
>> </unique>
>> </body>
>> <initialization>
>> tapestry.widget.synchronizeWidgetState("${id}", "dialog",
>>${props});
>>
>>dojo.widget.byId("${id}").setCloseControl(dojo.byId("${closer}"));
>> dojo.widget.byId("${id}").setShowControl(dojo.byId
("${shower}"));
>> </initialization>
>></script>
>>
>>So when I click on my shower (my form submit button) it pops up the
dialog
>>that has the closer (cancel button) and then instantaneously throws the
>>exception.
>>
>>It took me a lot longer than 10 minutes to make this (a couple of
hours!!)
>>but after it was done it all seems very simple. I just couldn't find any
>>documentation anywhere about it, so I just read through some source and
>>tried putting things together.
>>
>>When you say "I'm assuming it's not just a simple
>>dojo.widget.byId("yourDlgId").show()" are you implying that if it is
just
>>doing that, I ought to just use dojo directly in my template?
>>
>>Thanks,
>>Peter Beshai
>>
>>
>> >From: "Jesse Kuhnert" <[EMAIL PROTECTED]>
>> >Reply-To: "Tapestry users" <[email protected]>
>> >To: "Tapestry users" <[email protected]>
>> >Subject: Re: PageRenderSupport problem (Body component is in template)
>> >Date: Tue, 17 Oct 2006 22:54:39 -0400
>> >
>> >So what does it do after loading up? I'm assuming it's not just a
simple
>> >dojo.widget.byId("yourDlgId").show() ?
>> >
>> >I created the same component in 4.1.1 yesterday btw. (Took me all of
ten
>> >minutes!, of course that is expected..)
>> >
>> >On 10/17/06, Peter Beshai <[EMAIL PROTECTED]> wrote:
>> >>
>> >>Hi,
>> >>
>> >>I have created a wrapper for the dojo component Dialog and it works
>>fine
>> >>(in
>> >>general!), but I have a problem when I use it with my form. I want to
>>have
>> >>the dialog appear when I submit the form (ie, the form submit button
is
>> >>the
>> >>show controller) and the dialog will basically have a cancel button
>>(close
>> >>controller and Submit component with type cancel).
>> >>
>> >>The dialog loads fine, but soon after loading it throws an exception:
>> >>Component FileUpload/uploadingDialog requires rendering support, but
no
>> >>PageRenderSupport object has been stored into the request cycle. This
>> >>object
>> >>is typically provided by a Body component. You should add a Body
>>component
>> >>to your template.
>> >>
>> >>I do have a body component defined : <body jwcid="[EMAIL PROTECTED]">.
>> >>
>> >>Any ideas how to fix this problem?
>> >>
>> >>FYI in my Dialog.java file I have in the renderComponent function:
>> >>PageRenderSupport pageRenderSupport =
>> >>TapestryUtils.getPageRenderSupport(cycle, this);
>> >>getScript().execute(this, cycle, pageRenderSupport, scriptParms);
>> >>
>> >>
>> >>Peter Beshai
>> >>
>> >>_________________________________________________________________
>> >>Essayez la nouvelle génération de recherche avec Live Search.
>> >>http://www.live.com/?mkt=fr-ca
>> >>
>> >>
>> >>---------------------------------------------------------------------
>> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
>> >>For additional commands, e-mail: [EMAIL PROTECTED]
>> >>
>> >>
>> >
>> >
>> >--
>> >Jesse Kuhnert
>> >Tapestry/Dojo/(and a dash of TestNG), team member/developer
>> >
>> >Open source based consulting work centered around
>> >dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>>
>>_________________________________________________________________
>>Découvrez Live Search de votre PC ou de votre appareil mobile dès
>>aujourd'hui. http://www.live.com/?mkt=fr-ca
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
>
>--
>Jesse Kuhnert
>Tapestry/Dojo/(and a dash of TestNG), team member/developer
>
>Open source based consulting work centered around
>dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
_________________________________________________________________
Voyez vos amis en faisant un appel vidèo dans Windows Live Messenger
http://imagine-msn.com/messenger/launch80/default.aspx?locale=fr-ca
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Robert Ramírez Vique
Computer Science Engineer