You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Barry Books <tr...@gmail.com> on 2011/10/06 15:06:50 UTC

Using the same page for edit/new (Solution)

Some recent discussions caused me to revisit this problem

Ideally you could have a page like

public class NVLEdit {
	
	@PageActivationContext
	@Property
	@NVL
	private Person person;
	
        @CommitAfter
	Object onSuccess() {
		return NVLIndex.class;
	}

}

that can edit/create Objects, but for various reasons it quickly
becomes more complicated than that. I also wanted Person to be an
Interface to support multiple types of backing stores. What I came up
with was this:

1. Create NVL annotation (named after the SQL function)
2. Create a worker that populates the field if the value is null.
3. Add a hook so you can "persist" the object when needed.

The worker code (and examples) are here

https://github.com/trsvax/tapestry-trsvax/blob/master/src/main/java/com/trsvax/tapestry/misc/services/NVLWorker.java

You can add implementations for Interfaces with

    @Contribute(NVLService.class)
    public static void contributeFactories(Logger logger,
MappedConfiguration<Class, NVLFactory> configuration) {
    	configuration.add(Person.class,new ConstructorFactory(logger,
PersonImpl.class));
    }

Barry

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


Re: Using the same page for edit/new (Solution)

Posted by Muhammad Gelbana <m....@gmail.com>.
How about persisting a variable (on the client side using client-persisting
strategy) and inject your page in other pages then when navigating from
these pages set this variable to whatever suits you. So you can specify
the behavior of your page in a salable way I suppose and you solve the
multiple-tabs thing just in case the client is viewing your page from
different browsers\tabs.

Please tell me if i'm not clear.

On Tue, Dec 6, 2011 at 4:09 AM, Serge Eby <sd...@hotmail.com> wrote:

> Could you expand on this a little more?
> I am not using tapestry-hibernate and my current solution feels a bit
> awkward.
>
> /Serge
>
> --
> View this message in context:
> http://tapestry-users.832.n2.nabble.com/Using-the-same-page-for-edit-new-Solution-tp6865849p7065396.html
> Sent from the Tapestry Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
*Regards,*
*Muhammad Gelbana
Java Developer*

Re: Using the same page for edit/new (Solution)

Posted by Serge Eby <sd...@hotmail.com>.
Could you expand on this a little more?
I am not using tapestry-hibernate and my current solution feels a bit
awkward.

/Serge

--
View this message in context: http://tapestry-users.832.n2.nabble.com/Using-the-same-page-for-edit-new-Solution-tp6865849p7065396.html
Sent from the Tapestry Users mailing list archive at Nabble.com.

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


Re: Using the same page for edit/new (Solution)

Posted by Howard Lewis Ship <hl...@gmail.com>.
I recently changed Tapestry 5.3 so that the Hibernate ValueEncoder
(used implicitly by @PageActivationContext) will encode a transient
entity as null.  This makes it possible to use the same page for add
and edit, with a bit of smart logic in your onActivate() event handler
method.

On Thu, Oct 6, 2011 at 6:06 AM, Barry Books <tr...@gmail.com> wrote:
> Some recent discussions caused me to revisit this problem
>
> Ideally you could have a page like
>
> public class NVLEdit {
>
>        @PageActivationContext
>        @Property
>        @NVL
>        private Person person;
>
>        @CommitAfter
>        Object onSuccess() {
>                return NVLIndex.class;
>        }
>
> }
>
> that can edit/create Objects, but for various reasons it quickly
> becomes more complicated than that. I also wanted Person to be an
> Interface to support multiple types of backing stores. What I came up
> with was this:
>
> 1. Create NVL annotation (named after the SQL function)
> 2. Create a worker that populates the field if the value is null.
> 3. Add a hook so you can "persist" the object when needed.
>
> The worker code (and examples) are here
>
> https://github.com/trsvax/tapestry-trsvax/blob/master/src/main/java/com/trsvax/tapestry/misc/services/NVLWorker.java
>
> You can add implementations for Interfaces with
>
>    @Contribute(NVLService.class)
>    public static void contributeFactories(Logger logger,
> MappedConfiguration<Class, NVLFactory> configuration) {
>        configuration.add(Person.class,new ConstructorFactory(logger,
> PersonImpl.class));
>    }
>
> Barry
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

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