You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Cureau <cm...@gmail.com> on 2012/05/08 04:15:43 UTC

Zone refresh in form fragment 'wizard'

Hi there!

I'm following Geoff's excellent jumpstart on creating a wizard using form
fragments.  I've got it all working so far, but I want to create a summary
form fragment that displays a table with the text that was entered on the
previous form fragment panel.  The final page has a zone defined and
delegated to a block which appears at the bottom of the tml file.  Just
before I move on to the last panel, the onSuccess() routine sets some page
parameters that are defined in the tml file.  It then returns the block to
the page.  Problem is, the block never gets rendered.  I've looked through
the zone examples I've found posted, but none of them seems to do what I am
asking it to do.

Do I have to have a non-visible submit on the page to trigger the zone
update?  Or is there some magic that I'm missing?

Thanks in advance!

Re: Zone refresh in form fragment 'wizard'

Posted by Chris Cureau <cm...@gmail.com>.
No takers? Ah well...I'll break it into separate pages. I just wish I knew
what I was doing wrong. Maybe a renderobject in the template would help?

Igor, can't wait for your book!
On May 8, 2012 10:25 AM, "Chris Cureau" <cm...@gmail.com> wrote:

> I've looked at the form fragments in firebug. It doesn't appear that the
> form fragment is being changed at all except the visible attribute. I've
> pasted the output from firebug below:
>
> Before fragment 3:
>
> <div id="formfragment_1" class="t-invisible tapestry-formfragment">
> <input id="formfragment_1-hidden" type="hidden" name="t:formdata"
> value="H4sIAAAAAAAAAFvzloG1XI5BJjElNzNPPzW3ICe/MjVVPyS1uMSquDQpN7Mk3rC4iMEhvyhdL7EgMTkjVa8ksQAoW1RpqpecX5Sak5kEpHML8vNS80qK9YLBelQCivKTU4uLwbzi4sz8vJnBnyS3bmlxZmJg8mHgSM7JBKr2TClhEPLJSixL1M9JzEvXDy4pysxLt/Zh4E7NSc0FKvBLzE0tZKhjYKwoKGHggDrHCIkJAH81VIC+AAAA">
> <h2>That's all we need!</h2>
> <p></p>
> Please verify the following information:
> <p></p>
> <div id="summaryZone" class="t-zone tapestry-zone"></div>
> <p></p>
> To complete this employee, press the
> <em>Finish</em>
> button.
> <p></p>
>
> On fragment 3:
> <div id="formfragment_1" class="tapestry-formfragment">
> <input id="formfragment_1-hidden" type="hidden" name="t:formdata"
> value="H4sIAAAAAAAAAFvzloG1XI5BJjElNzNPPzW3ICe/MjVVPyS1uMSquDQpN7Mk3rC4iMEhvyhdL7EgMTkjVa8ksQAoW1RpqpecX5Sak5kEpHML8vNS80qK9YLBelQCivKTU4uLwbzi4sz8vJnBnyS3bmlxZmJg8mHgSM7JBKr2TClhEPLJSixL1M9JzEvXDy4pysxLt/Zh4E7NSc0FKvBLzE0tZKhjYKwoKGHggDrHCIkJAH81VIC+AAAA">
> <h2>That's all we need!</h2>
> <p></p>
> Please verify the following information:
> <p></p>
> <div id="summaryZone" class="t-zone tapestry-zone"></div>
> <p></p>
> To complete this employee, press the
> <em>Finish</em>
> button.
> <p></p>
>
>
> On May 8, 2012 10:15 AM, "Thiago H. de Paula Figueiredo" <
> thiagohp@gmail.com> wrote:
>
>> On Tue, 08 May 2012 11:19:02 -0300, Chris Cureau <cm...@gmail.com>
>> wrote:
>>
>>  I've just added a few more debugging statements... isInSubmit() is
>>> getting called before each fragment rendering phase.  It returns false on
>>> the first two fragments and true on the last.
>>>
>>> What I see is this: The first and second fragments work as expected...the
>>> first just presenting text, and the second accepting input with
>>> beaneditor.  The third fragment (submit) shows everything EXCEPT for the
>>> zone that is set in it.  I am returning the block in onSuccess() when I
>>> change the fragment from General to Submit (fragment 2 to 3).  No
>>> exceptions are shown.  It is almost as if Tapestry is ignoring the block
>>> altogether.
>>>
>>
>> Have you checked what Tapestry is returning in Firebug or some similar
>> tool? Are you sure you're returning a non-null block?
>>
>> --
>> 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<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>

Re: Zone refresh in form fragment 'wizard'

Posted by Chris Cureau <cm...@gmail.com>.
I've looked at the form fragments in firebug. It doesn't appear that the
form fragment is being changed at all except the visible attribute. I've
pasted the output from firebug below:

Before fragment 3:

<div id="formfragment_1" class="t-invisible tapestry-formfragment">
<input id="formfragment_1-hidden" type="hidden" name="t:formdata"
value="H4sIAAAAAAAAAFvzloG1XI5BJjElNzNPPzW3ICe/MjVVPyS1uMSquDQpN7Mk3rC4iMEhvyhdL7EgMTkjVa8ksQAoW1RpqpecX5Sak5kEpHML8vNS80qK9YLBelQCivKTU4uLwbzi4sz8vJnBnyS3bmlxZmJg8mHgSM7JBKr2TClhEPLJSixL1M9JzEvXDy4pysxLt/Zh4E7NSc0FKvBLzE0tZKhjYKwoKGHggDrHCIkJAH81VIC+AAAA">
<h2>That's all we need!</h2>
<p></p>
Please verify the following information:
<p></p>
<div id="summaryZone" class="t-zone tapestry-zone"></div>
<p></p>
To complete this employee, press the
<em>Finish</em>
button.
<p></p>

On fragment 3:
<div id="formfragment_1" class="tapestry-formfragment">
<input id="formfragment_1-hidden" type="hidden" name="t:formdata"
value="H4sIAAAAAAAAAFvzloG1XI5BJjElNzNPPzW3ICe/MjVVPyS1uMSquDQpN7Mk3rC4iMEhvyhdL7EgMTkjVa8ksQAoW1RpqpecX5Sak5kEpHML8vNS80qK9YLBelQCivKTU4uLwbzi4sz8vJnBnyS3bmlxZmJg8mHgSM7JBKr2TClhEPLJSixL1M9JzEvXDy4pysxLt/Zh4E7NSc0FKvBLzE0tZKhjYKwoKGHggDrHCIkJAH81VIC+AAAA">
<h2>That's all we need!</h2>
<p></p>
Please verify the following information:
<p></p>
<div id="summaryZone" class="t-zone tapestry-zone"></div>
<p></p>
To complete this employee, press the
<em>Finish</em>
button.
<p></p>


On May 8, 2012 10:15 AM, "Thiago H. de Paula Figueiredo" <th...@gmail.com>
wrote:

> On Tue, 08 May 2012 11:19:02 -0300, Chris Cureau <cm...@gmail.com>
> wrote:
>
>  I've just added a few more debugging statements... isInSubmit() is
>> getting called before each fragment rendering phase.  It returns false on
>> the first two fragments and true on the last.
>>
>> What I see is this: The first and second fragments work as expected...the
>> first just presenting text, and the second accepting input with
>> beaneditor.  The third fragment (submit) shows everything EXCEPT for the
>> zone that is set in it.  I am returning the block in onSuccess() when I
>> change the fragment from General to Submit (fragment 2 to 3).  No
>> exceptions are shown.  It is almost as if Tapestry is ignoring the block
>> altogether.
>>
>
> Have you checked what Tapestry is returning in Firebug or some similar
> tool? Are you sure you're returning a non-null block?
>
> --
> 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<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Zone refresh in form fragment 'wizard'

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 08 May 2012 11:19:02 -0300, Chris Cureau <cm...@gmail.com>  
wrote:

> I've just added a few more debugging statements... isInSubmit() is  
> getting called before each fragment rendering phase.  It returns false  
> on the first two fragments and true on the last.
>
> What I see is this: The first and second fragments work as expected...the
> first just presenting text, and the second accepting input with
> beaneditor.  The third fragment (submit) shows everything EXCEPT for the
> zone that is set in it.  I am returning the block in onSuccess() when I
> change the fragment from General to Submit (fragment 2 to 3).  No
> exceptions are shown.  It is almost as if Tapestry is ignoring the block
> altogether.

Have you checked what Tapestry is returning in Firebug or some similar  
tool? Are you sure you're returning a non-null block?

-- 
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: Zone refresh in form fragment 'wizard'

Posted by Chris Cureau <cm...@gmail.com>.
I've just added a few more debugging statements... isInSubmit() is getting
called before each fragment rendering phase.  It returns false on the first
two fragments and true on the last.

What I see is this: The first and second fragments work as expected...the
first just presenting text, and the second accepting input with
beaneditor.  The third fragment (submit) shows everything EXCEPT for the
zone that is set in it.  I am returning the block in onSuccess() when I
change the fragment from General to Submit (fragment 2 to 3).  No
exceptions are shown.  It is almost as if Tapestry is ignoring the block
altogether.

On Tue, May 8, 2012 at 8:57 AM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, 08 May 2012 10:48:38 -0300, Chris Cureau <cm...@gmail.com>
> wrote:
>
>  Hi Thiago!
>>
>
> Hi!
>
>
>  Thanks for the quick response.  I put together a smaller version of my
>> page to save some space.  It exhibits the same problems.  No exceptions are
>> thrown in the console, but I can see my page going through onSuccess
>> properly because of a printf I put in there.
>>
>
> What exactly is happening? Are you sure the isInSubmit() returns true when
> you're rendering the FormFragment?
>
>
> --
> 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
>

Re: Zone refresh in form fragment 'wizard'

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 08 May 2012 10:48:38 -0300, Chris Cureau <cm...@gmail.com>  
wrote:

> Hi Thiago!

Hi!

> Thanks for the quick response.  I put together a smaller version of my  
> page to save some space.  It exhibits the same problems.  No exceptions  
> are
> thrown in the console, but I can see my page going through onSuccess
> properly because of a printf I put in there.

What exactly is happening? Are you sure the isInSubmit() returns true when  
you're rendering the FormFragment?

-- 
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: Zone refresh in form fragment 'wizard'

Posted by Chris Cureau <cm...@gmail.com>.
Hi Thiago!

Thanks for the quick response.  I put together a smaller version of my page
to save some space.  It exhibits the same problems.  No exceptions are
thrown in the console, but I can see my page going through onSuccess
properly because of a printf I put in there.

I did see another example just a few minutes ago (again in Jumpstart) that
has an Ajax OnEvent zone updater mixin...maybe this is what I am missing?


Class:

package net.cureau.timeclock.pages.admin.employee;

import net.cureau.commons.Conversations;
import net.cureau.timeclock.entities.employee.Employee;
import net.cureau.timeclock.pages.admin.AdminBadFlow;
import net.cureau.timeclock.pages.admin.AdminIndex;
import org.apache.tapestry5.Block;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.annotations.SessionState;
import org.apache.tapestry5.corelib.components.Form;

public class EmployeeTest {
 public static final String WIZARD_CONVERSATION_PREFIX = "wiz";
public static final String EMPLOYEE_KEY = "EMPL";
 public enum Step {
START, GENERAL, SUBMIT, SUCCESS, BAD_FLOW
 }

// The activation context

private String conversationId = null;

private Step step = null;

// The conversation and its contents

@SessionState
private Conversations conversations;

 @Property
private Employee employee;
 // Page fields
 @Property
 private String formattedName;
 @Property
 private Block summaryBlock;
  // Other pages

@InjectPage
private AdminIndex adminIndexPage;
 @InjectPage
private AdminBadFlow badFlowPage;

// Generally useful bits and pieces

@Component(id = "form")
 private Form form;

// The code

public void set(Step step, String conversationId) {
 this.step = step;
this.conversationId = conversationId;
}

Object[] onPassivate() {
return new Object[] { step, conversationId };
 }

Object onActivate() {
if (step == null) {
 startConversation();
step = Step.START;
return this;
 }
return null;
}

Object onActivate(Step step, String conversationId) throws Exception {
this.step = step;
 this.conversationId = conversationId;

if (this.step == null) {
 startConversation();
this.step = Step.START;
return this;
 }

// If the conversation does not contain the model
// then it means the Back/Reload/Refresh button has been used to reach
 // an old conversation,
// so redirect to the bad-flow-step

 if (restoreEmployeeFromConversation() == null) {
return badFlowPage;
}

return null;
}

void onPrepare() {
 if (employee == null) {
// Get objects for the form fields to overlay.
 employee = restoreEmployeeFromConversation();
}
}
 void onValidateFromForm() {
 // Handle server side validations first
if (form.getHasErrors()) {
return;
 }
 saveEmployeeToConversation(employee);
 }
 public Object onSuccess() {
 System.out.println("In onSuccess()");
switch (step) {
case START:
 step = Step.GENERAL;
return null;
case GENERAL:
 generateFormattedStrings();
step = Step.SUBMIT;
return summaryBlock;
 case SUBMIT:
endConversation();
// Save records here
 return adminIndexPage;
default:
throw new IllegalStateException("Should not get here. step = " + step);
 }
}
 void onPrev() {
switch (step) {
case SUBMIT:
 step = Step.GENERAL;
break;
case GENERAL:
 step = Step.START;
break;
default:
 throw new IllegalStateException("Should not get here. step = " + step);
}
 }
 void onRestart() {
 step = null;
}

Object onQuit() {
 endConversation();
return adminIndexPage;
}
 public void startConversation() {
conversationId = conversations
 .startConversation(WIZARD_CONVERSATION_PREFIX);
this.employee = new Employee();
 saveEmployeeToConversation(employee);
}

private void saveEmployeeToConversation(Employee employee) {
 conversations.saveToConversation(conversationId, EMPLOYEE_KEY, employee);
}

private Employee restoreEmployeeFromConversation() {
return (Employee) conversations.restoreFromConversation(conversationId,
 EMPLOYEE_KEY);
}
 private void endConversation() {
conversations.endConversation(conversationId);

// If conversations SSO is now empty then remove it from the session

if (conversations.isEmpty()) {
 conversations = null;
}
}

public boolean isInEntrySteps() {
return step == Step.START || step == Step.GENERAL || step == Step.SUBMIT;
 }

public boolean isInStart() {
return step == Step.START;
 }

public boolean isInGeneral() {
return step == Step.GENERAL;
 }
 public boolean isInSubmit() {
 return step == Step.SUBMIT;
}

public boolean isInBadFlow() {
 return step == Step.BAD_FLOW;
}
 private void generateFormattedStrings() {
formattedName = employee.getFormattedName();
 }
}

Template:

<html t:type="layout" title="Timeclock Administration"
 t:sidebarTitle="Framework Version"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd"
 xmlns:p="tapestry:parameter">

<t:if test="inEntrySteps">
<form t:type="form" t:id="form"
 style="background: #EEEEEE; padding: 1em;">
<t:formfragment visible="inStart">
 <h2>Wizard</h2>
<p />
This wizard will guide you through the process of creating a new
 employee. In this wizard, you will define the name, addresses,
phone number, email addresses, and time clock sign in codes for
 each employee who needs access. If you wish to cancel at any time,
press the Cancel button below. Otherwise, press Next to continue.
 <p />
<div align="right">
<t:eventlink t:event="Quit" t:mixins="jquery/button"
 style="color: #1C94C4">Cancel</t:eventlink>
<t:submit t:mixins="jquery/button" value="Next &gt;" />
 </div>
</t:formfragment>
<t:formfragment visible="inGeneral">
 <h2>General Information</h2>
<p />
<div class="t-beaneditor">
 <div t:type="beanEditor" object="employee" />
</div>
 <p />
<div align="right">
<t:eventlink t:event="Quit" t:mixins="jquery/button"
 style="color: #1C94C4">Cancel</t:eventlink>
<t:eventlink t:event="Prev" t:mixins="jquery/button"
 style="color: #1C94C4">&lt; Previous</t:eventlink>
<t:submit t:mixins="jquery/button" value="Next &gt;" />
 </div>
</t:formfragment>
<t:formfragment visible="inSubmit">
 <h2>That's all we need!</h2>
<p />
Please verify the following information:
 <p />
<t:zone t:id="summaryZone" id="summaryZone" update="show">
 <t:delegate t:to="summaryBlock" />
</t:zone>
<p />
 To complete this employee, press the <em>Finish</em> button.
<p />
 <div align="right">
<t:eventlink t:event="Quit" t:mixins="jquery/button"
 style="color: #1C94C4">Cancel</t:eventlink>
<t:eventlink t:event="Prev" t:mixins="jquery/button"
 style="color: #1C94C4">&lt; Previous</t:eventlink>
<t:submit t:mixins="jquery/button" value="Finish" />
 </div>
</t:formfragment>
</form>
 <t:block t:id="summaryBlock">
<table style="float: center">
 <tr>
<td align="right">Full Name:</td>
<td>${formattedName}</td>
 </tr>
</table>
</t:block>
</t:if>
<t:if test="inBadFlow">
<div style="background: #EEAAAA; padding: 1em;">
Operation not allowed because the Employee Add sequence is over. Did
 you use the Back button after the Entry was finished?<br />
<br /> <a t:type="eventlink" t:event="Restart" href="#">Start
 again</a>
</div>
</t:if>
</html>


On Mon, May 7, 2012 at 9:32 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Mon, 07 May 2012 23:15:43 -0300, Chris Cureau <cm...@gmail.com>
> wrote:
>
>  Hi there!
>>
>
> Hi!
>
> Please post the template and code please, at least the relevant parts
> (events, form submissions, links, etc). In addition, some exception or
> error should have been raised. Please take a look at the console output and
> check for exceptions.
>
> --
> 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
>

Re: Zone refresh in form fragment 'wizard'

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 07 May 2012 23:15:43 -0300, Chris Cureau <cm...@gmail.com>  
wrote:

> Hi there!

Hi!

Please post the template and code please, at least the relevant parts  
(events, form submissions, links, etc). In addition, some exception or  
error should have been raised. Please take a look at the console output  
and check for exceptions.

-- 
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