You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Joel Wiegman <Jo...@btservices.com> on 2007/05/15 19:20:45 UTC
T5: Flash persistence strategy
Greetings all,
I attempted to expand upon the T5 "FlashDemo" found here:
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/
test/app1/WEB-INF/
I'm attempting to write a "Messages" component that can be included
anywhere and show a group of messages to a user.
But for some reason the messages are persisting past a single-page
rendering, despite using the new "flash" persistence strategy (which I'm
assuming is available in 5.0.4). Can anyone spot the flaw? Thanks!
"Messages" component:
@Meta("tapestry.persistence-strategy=flash")
public class Messages {
@Persist
private List<String> messages = new ArrayList<String>();
@Persist
private String currentMessage;
public List<String> getMessages()
{
return messages;
}
public void addMessage(String message) {
messages.add(message);
}
public String getCurrentMessage() {
return currentMessage;
}
public void setCurrentMessage(String currentMessage) {
this.currentMessage = currentMessage;
}
}
"Messages" template:
<t:if test="messages"
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
<ul>
<li t:type="loop" source="messages"
value="currentMessage">
${currentMessage}
</li>
</ul>
</t:if>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
T5: JavaOne BOF Source
Posted by Alex Fishlock <al...@racingjag.com>.
Howard,
Is there any way you could release some/all of the source that you
presented at Javaone.
I am stuck with grid, and you did something in your session that would fix
it for me.
Alex.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Flash persistence strategy
Posted by Howard Lewis Ship <hl...@gmail.com>.
It works and is tested; perhaps there's a bug when the property being
persisted is inside a component and not a page (but I really doubt it).
On 5/15/07, Joel Wiegman <Jo...@btservices.com> wrote:
>
> Thanks Howard. I figured I didn't need it on the currentMessage field,
> but I didn't want the flex response from someone saying I should try
> adding it. ;-)
>
> Either way, the "messages" field is still sticking around past a single
> page load.
>
> The pertinent java code that uses it is:
>
> @Component
> private Messages messages;
>
> Object onActionFromDownloadDistrict(String districtId) {
> messages.addMessage("Last successful download: District " +
> districtId);
> return null;
> }
>
>
> And of course the html:
>
> <t:messages/>
>
> Anything else I'm missing? Is flash persistence available in 5.0.4?
>
>
> -----Original Message-----
> From: Howard Lewis Ship [mailto:hlship@gmail.com]
> Sent: Tuesday, May 15, 2007 1:48 PM
> To: Tapestry users
> Subject: Re: T5: Flash persistence strategy
>
> You don't need the @Meta, you can:
>
> @Persist("flash")
> private List<String> messages = new ArrayList<String>();
>
>
> Also, you don't need the @Persist on the currentMessage field.
>
> On 5/15/07, Joel Wiegman <Jo...@btservices.com> wrote:
> >
> > Greetings all,
> >
> > I attempted to expand upon the T5 "FlashDemo" found here:
> >
> > http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/sr
> > c/
> > test/app1/WEB-INF/
> >
> > I'm attempting to write a "Messages" component that can be included
> > anywhere and show a group of messages to a user.
> >
> > But for some reason the messages are persisting past a single-page
> > rendering, despite using the new "flash" persistence strategy (which
> > I'm assuming is available in 5.0.4). Can anyone spot the flaw?
> Thanks!
> >
> > "Messages" component:
> >
> > @Meta("tapestry.persistence-strategy=flash")
> > public class Messages {
> >
> > @Persist
> > private List<String> messages = new ArrayList<String>();
> >
> > @Persist
> > private String currentMessage;
> >
> > public List<String> getMessages()
> > {
> > return messages;
> > }
> >
> > public void addMessage(String message) {
> > messages.add(message);
> > }
> >
> > public String getCurrentMessage() {
> > return currentMessage;
> > }
> >
> > public void setCurrentMessage(String currentMessage) {
> > this.currentMessage = currentMessage;
> > }
> >
> > }
> >
> > "Messages" template:
> >
> > <t:if test="messages"
> > xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> > <ul>
> > <li t:type="loop" source="messages"
> > value="currentMessage">
> > ${currentMessage}
> > </li>
> > </ul>
> > </t:if>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> Howard M. Lewis Ship
> TWD Consulting, Inc.
> Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
> Apache Tapestry Creator, Apache HiveMind
>
> Professional Tapestry training, mentoring, support and project work.
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind
Professional Tapestry training, mentoring, support
and project work. http://howardlewisship.com
RE: T5: Flash persistence strategy
Posted by Joel Wiegman <Jo...@btservices.com>.
Thanks Howard. I figured I didn't need it on the currentMessage field,
but I didn't want the flex response from someone saying I should try
adding it. ;-)
Either way, the "messages" field is still sticking around past a single
page load.
The pertinent java code that uses it is:
@Component
private Messages messages;
Object onActionFromDownloadDistrict(String districtId) {
messages.addMessage("Last successful download: District " +
districtId);
return null;
}
And of course the html:
<t:messages/>
Anything else I'm missing? Is flash persistence available in 5.0.4?
-----Original Message-----
From: Howard Lewis Ship [mailto:hlship@gmail.com]
Sent: Tuesday, May 15, 2007 1:48 PM
To: Tapestry users
Subject: Re: T5: Flash persistence strategy
You don't need the @Meta, you can:
@Persist("flash")
private List<String> messages = new ArrayList<String>();
Also, you don't need the @Persist on the currentMessage field.
On 5/15/07, Joel Wiegman <Jo...@btservices.com> wrote:
>
> Greetings all,
>
> I attempted to expand upon the T5 "FlashDemo" found here:
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/sr
> c/
> test/app1/WEB-INF/
>
> I'm attempting to write a "Messages" component that can be included
> anywhere and show a group of messages to a user.
>
> But for some reason the messages are persisting past a single-page
> rendering, despite using the new "flash" persistence strategy (which
> I'm assuming is available in 5.0.4). Can anyone spot the flaw?
Thanks!
>
> "Messages" component:
>
> @Meta("tapestry.persistence-strategy=flash")
> public class Messages {
>
> @Persist
> private List<String> messages = new ArrayList<String>();
>
> @Persist
> private String currentMessage;
>
> public List<String> getMessages()
> {
> return messages;
> }
>
> public void addMessage(String message) {
> messages.add(message);
> }
>
> public String getCurrentMessage() {
> return currentMessage;
> }
>
> public void setCurrentMessage(String currentMessage) {
> this.currentMessage = currentMessage;
> }
>
> }
>
> "Messages" template:
>
> <t:if test="messages"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <ul>
> <li t:type="loop" source="messages"
> value="currentMessage">
> ${currentMessage}
> </li>
> </ul>
> </t:if>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant Creator and PMC Chair,
Apache Tapestry Creator, Apache HiveMind
Professional Tapestry training, mentoring, support and project work.
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Flash persistence strategy
Posted by Howard Lewis Ship <hl...@gmail.com>.
You don't need the @Meta, you can:
@Persist("flash")
private List<String> messages = new ArrayList<String>();
Also, you don't need the @Persist on the currentMessage field.
On 5/15/07, Joel Wiegman <Jo...@btservices.com> wrote:
>
> Greetings all,
>
> I attempted to expand upon the T5 "FlashDemo" found here:
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/
> test/app1/WEB-INF/
>
> I'm attempting to write a "Messages" component that can be included
> anywhere and show a group of messages to a user.
>
> But for some reason the messages are persisting past a single-page
> rendering, despite using the new "flash" persistence strategy (which I'm
> assuming is available in 5.0.4). Can anyone spot the flaw? Thanks!
>
> "Messages" component:
>
> @Meta("tapestry.persistence-strategy=flash")
> public class Messages {
>
> @Persist
> private List<String> messages = new ArrayList<String>();
>
> @Persist
> private String currentMessage;
>
> public List<String> getMessages()
> {
> return messages;
> }
>
> public void addMessage(String message) {
> messages.add(message);
> }
>
> public String getCurrentMessage() {
> return currentMessage;
> }
>
> public void setCurrentMessage(String currentMessage) {
> this.currentMessage = currentMessage;
> }
>
> }
>
> "Messages" template:
>
> <t:if test="messages"
> xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <ul>
> <li t:type="loop" source="messages"
> value="currentMessage">
> ${currentMessage}
> </li>
> </ul>
> </t:if>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind
Professional Tapestry training, mentoring, support
and project work. http://howardlewisship.com