You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Dawn <pe...@gmail.com> on 2006/09/18 00:05:12 UTC

Passing on information from one page to another

guys,

i have a form which a user fills in with their information. now when
they click on submit, i want to display a confirmation page,
displaying all the information the user has already filled in and once
they confirm process the information.

now how can i pass on information from one page to another. i mean
somehow i need to send this information from the form page to the
confirmation page and display it for confirmation.

any ideas. thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Passing on information from one page to another

Posted by Daniel Jue <te...@gmail.com>.
I have some pages that do exactly what you want.  They are for Tapestry 4.
Imports not shown.

The edit settings page displays a user setting in a textbox that was
stored in a user object.
When you save the form, it takes the value in the text box (may have
changed) and stores it back in the user object.  It then forwards you
to a page that is very similar, except it just displays the settings
you stored (no editing allowed).

In my real application the user object has a user settings object in
it.  Inside the user settings object I have lots of actual settings.
This code is based off of chapter 2 of Enjoying Web Development with
Tapestry.  That chapter is free online.

EditSettings.java
public abstract class EditSettings extends BasePage implements
		PageValidateListener {
  @InjectPage("ShowSettings")
  abstract public ShowSettings getShowSettingsPage();
  public IPage onSave(IRequestCycle cycle) {
    getUser().setSomeUserSetting(getSomeUserSetting());
    ShowSettings resultPage = getShowSettingsPage();
    return resultPage;
  }
  @InitialValue("getUser().SomeUserSetting()")
  abstract public String getSomeUserSetting();

  @InjectState("user")
  public abstract User getUser();

}


EditSettings.html
<form jwcid="EditSettingsForm">
<table><tr><td>User Setting:</td>
    <td><input type="text" jwcid="SomeUserSetting@TextField"
value="ognl:SomeUserSetting" /></td></tr></table>
</form>

EditSettings.page
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
  "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
  "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification class="EditSettings">
    <component id="EditSettingsForm" type="Form">
        <binding name="listener" value="listener:onSave"/>
    </component>
</page-specification>


ShowSettings.java
public abstract class ShowSettings extends BasePage implements
		PageValidateListener {
  @InjectState("user")
  public abstract User getUser();

  @InitialValue("getUser().getSomeUserSetting()")
  abstract public String getSomeusersetting();
}

ShowSettings.html
<p>The setting is: <span jwcid=@Insert value="ognl:someusersetting" /></p>

ShowSettings.page has nothing defined in it, just the dtd, etc.




On 9/18/06, Onno Scheffers <on...@piraya.nl> wrote:
> Peter Dawn schreef:
>
> > guys,
> >
> > i have a form which a user fills in with their information. now when
> > they click on submit, i want to display a confirmation page,
> > displaying all the information the user has already filled in and once
> > they confirm process the information.
> >
> > now how can i pass on information from one page to another. i mean
> > somehow i need to send this information from the form page to the
> > confirmation page and display it for confirmation.
>
> Hi Peter,
>
> have you tried this from your listener method on the Form Page?
>
> YourConfirmationPage page = (YourConfirmationPage)
> cycle.getPage("YourConfirmationPage");
> page.setValue1(value1);
> page.setValue2(value2);
>
> or you could just put all properties into a bean and set everything at once.
>
> Since the confirmation-page has no form-components (display-only) you
> also need a way to pass the values on over the next submit (user
> confirmation).
> You can either use hidden values for that or make the properties persistent.
>
> Regards,
>
> Onno
>
>
> ---------------------------------------------------------------------
> 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


Re: Passing on information from one page to another

Posted by Onno Scheffers <on...@piraya.nl>.
Peter Dawn schreef:

> guys,
>
> i have a form which a user fills in with their information. now when
> they click on submit, i want to display a confirmation page,
> displaying all the information the user has already filled in and once
> they confirm process the information.
>
> now how can i pass on information from one page to another. i mean
> somehow i need to send this information from the form page to the
> confirmation page and display it for confirmation.

Hi Peter,

have you tried this from your listener method on the Form Page?

YourConfirmationPage page = (YourConfirmationPage) 
cycle.getPage("YourConfirmationPage");
page.setValue1(value1);
page.setValue2(value2);

or you could just put all properties into a bean and set everything at once.

Since the confirmation-page has no form-components (display-only) you 
also need a way to pass the values on over the next submit (user 
confirmation).
You can either use hidden values for that or make the properties persistent.

Regards,

Onno


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org