You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nicolas Bouillon <ni...@bouil.org> on 2010/09/14 13:28:49 UTC
Submitting form with a zone or not, depending on submit button choosed
Hi,
I would like to be able to refresh a zone of a form if the user clicks one
button, or simply submit the form with a full page change if the user
clicks on another button.
But the zone attribute is on the "t:form" component, and not on the
t:submit component.
Did somebody see a way to achieve this behaviour ?
Thanks.
Nicolas.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Submitting form with a zone or not, depending on submit button choosed
Posted by Nicolas Bouillon <ni...@bouil.org>.
Thank you so much, it works very well.
For the record, here is my test code :
public class Ajax {
@Property
private String selectValue;
@Property
private String fieldValue;
@Inject
@Property
private Block formBlock;
@OnEvent(value = EventConstants.SELECTED, component = "submitBtn")
public void submitFromButton() {
reloadPage = false;
}
private boolean reloadPage = true;
public Object onSuccess() {
fieldValue = fieldValue + " / "
+ Long.toString(System.currentTimeMillis());
if (reloadPage) {
return formBlock;
} else {
return Index.class;
}
}
}
<html t:type="layout"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd"
xmlns:p="tapestry:parameter">
<t:zone id="updateZone">
<t:delegate to="formBlock" />
</t:zone>
<t:block t:id="formBlock">
<t:form zone="updateZone">
<t:select model="literal:1,2,3" value="selectValue"
onChange="this.form.fire(Tapestry.FORM_PROCESS_SUBMIT_EVENT)" />
<t:textfield value="fieldValue" />
<t:submit t:id="submitBtn" />
</t:form>
</t:block>
</html>
On Wed, 15 Sep 2010 10:21:16 -0300, "Thiago H. de Paula Figueiredo"
<th...@gmail.com> wrote:
> On Wed, 15 Sep 2010 09:54:36 -0300, Nicolas Bouillon <ni...@bouil.org>
> wrote:
>
>> Hi,
>
> Hi!
>
>> Maybe the explanation of my problem was not clear enough (or there is
no
>> solution ?)...
>>
>> So i have the following template :
>>
>> <t:form>
>> <t:select model="selectModel" value="selectValue"
>> onchange="this.form.submit()" />
>
> This JavaScript snippet doesn't trigger an AJAX form submission. Use
> $(formId).fire(Tapestry.FORM_PROCESS_SUBMIT_EVENT);, where formId is
> the client id of your form. That's exactly how Tapestry itself does AJAX
> form submissions.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Submitting form with a zone or not, depending on submit button
choosed
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 15 Sep 2010 09:54:36 -0300, Nicolas Bouillon <ni...@bouil.org>
wrote:
> Hi,
Hi!
> Maybe the explanation of my problem was not clear enough (or there is no
> solution ?)...
>
> So i have the following template :
>
> <t:form>
> <t:select model="selectModel" value="selectValue"
> onchange="this.form.submit()" />
This JavaScript snippet doesn't trigger an AJAX form submission. Use
$(formId).fire(Tapestry.FORM_PROCESS_SUBMIT_EVENT);, where formId is
the client id of your form. That's exactly how Tapestry itself does AJAX
form submissions.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Submitting form with a zone or not, depending on submit button choosed
Posted by Nicolas Bouillon <ni...@bouil.org>.
Hi,
Maybe the explanation of my problem was not clear enough (or there is no
solution ?)...
So i have the following template :
<t:form>
<t:select model="selectModel" value="selectValue"
onchange="this.form.submit()" />
[... other form inputs and data ...]
<t:submit t:id="submitBtn" />
</t:form>
and on the java side i have
@OnEvent(value = EventConstants.SELECTED, component = "submitBtn")
public void submitFromButton() {
reloadPage = false;
}
private boolean reloadPage = true;
public Class onSuccess() throws DAOException {
if (reloadPage) {
return null;
} else {
return ViewCart.class;
}
}
I would like to avoid the full page reload when the select changes, and to
just update a zone (which will be the form itself).
Thanks for any help !
Nicolas.
On Tue, 14 Sep 2010 13:28:49 +0200, Nicolas Bouillon <ni...@bouil.org>
wrote:
> Hi,
>
> I would like to be able to refresh a zone of a form if the user clicks
one
> button, or simply submit the form with a full page change if the user
> clicks on another button.
>
> But the zone attribute is on the "t:form" component, and not on the
> t:submit component.
>
> Did somebody see a way to achieve this behaviour ?
>
> Thanks.
> Nicolas.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org