You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by iberck <ib...@gmail.com> on 2010/10/04 22:29:36 UTC

[T5.2] Principle 1, Static Structure Dynamic Behaviour

Hi forum,

I have a question, 

since T5.2 does't use a pages pool, what happend with Tapestry principle 1?
Now, can we have a more flexible component framework? :)


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3198357.html
Sent from the Tapestry - User 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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Oct 2010 02:41:18 -0300, iberck <ib...@gmail.com> wrote:

> Hi, thank you for the response

Hi!

> So I don't understand the principle
>
> 1. What happend if I add a html element in the tree dom and I get the  
> value from the request after submit ?
> I'm violating the principle?

You are not violating the principle. The static structure we're talking  
about is the page and component instances, not the result of their  
rendering.

> Is there a problem if I do that?

No problem at all. :)

-- 
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: Injecting Tapestry Services into Spring beans

Posted by Jeshurun Daniel <sj...@yahoo.ca>.
Hi Kai,
Actually it was working all the time. I was injecting @Session instead of @Request to get a session and was getting the exception no Service implemented it. I was able to inject a (not null) request object, but the session in it was still null, probably because this was too early in the pipeline or something (this was in the authentication service). I did find a couple of workarounds for my requirements and maybe they will help you too.
I wanted to inject Tapestry services into spring beans for two reasons:

1. I wanted access to Tapestry's Messages service to inject some properties I had defined in app.properties. Instead of injecting messages I just did this
<bean id="propertyConfigurer"
		class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="locations">
			<list>
				<value>/WEB-INF/app.properties</value>
				<value>/WEB-INF/security.properties</value>
				<value>/WEB-INF/hibernate.properties</value>
			</list>
		</property>
	</bean>
and then just using ${property.name} to inject the properties into my Spring beans.
2. I was using Spring's LDAP authentication provider and I wanted to store a User object in session once a user was successfully authenticated (and was hence trying to inject @Request). I got around this by extending Spring's LdapAuthenticationProvider and override its authenticate method. I was then able to store a user object in session like this.
@Override
	public Authentication authenticate(Authentication authentication)
			throws AuthenticationException {
		authentication = super.authenticate(authentication);
		if(null != authentication && authentication.isAuthenticated()){			
			HttpServletRequest httpRequest = globals.getHTTPServletRequest();
HttpSession session = httpRequest.getSession(false);
 		User user = new User();
			user.setUsername(authentication.getName());
 		User daoUser = userDao.getUser(authentication.getName());
			if(null != user){
 		 // fill some user details from the database such as name and email
			}else{
 			// I just send an email to myself here saying this user doesn't have a profile, even though they logged in successfully from the ldap.
				}
			}
 		session.setAttribute("sso:my.app.path.to.your.user.object.User", user);
		}
		return authentication;
	}

You can just inject the user object anywhere in your page classes by using@SessionStateprivate User user;private boolean userExists;
There are two downsides to this.1. If something goes wrong at this point, the user gets a full blown container error page, instead of your pretty error page defined in tapestry.2. If you restart your servlet container when the user is logged in (not that you would do that in production), the session object disappears even though Spring security still says the user is logged in. I haven't found a way around this yet.
I hope this helps.
Thanks,Jeshurun
--- On Wed, 10/6/10, Kai Weber <ka...@glorybox.de> wrote:

From: Kai Weber <ka...@glorybox.de>
Subject: Re: Injecting Tapestry Services into Spring beans
To: users@tapestry.apache.org
Received: Wednesday, October 6, 2010, 9:59 AM

* Jeshurun Daniel <sj...@yahoo.ca>:

> Ok please ignore that it was just me being stupid. I got it working
> now. Thanks.

Could you tell us, what you had to do to got it working?

Kai

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




Re: Injecting Tapestry Services into Spring beans

Posted by Kai Weber <ka...@glorybox.de>.
* Jeshurun Daniel <sj...@yahoo.ca>:

> Ok please ignore that it was just me being stupid. I got it working
> now. Thanks.

Could you tell us, what you had to do to got it working?

Kai

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


Re: Injecting Tapestry Services into Spring beans

Posted by Jeshurun Daniel <sj...@yahoo.ca>.
Ok please ignore that it was just me being stupid. I got it working now. Thanks.

--- On Tue, 10/5/10, Jeshurun Daniel <sj...@yahoo.ca> wrote:

From: Jeshurun Daniel <sj...@yahoo.ca>
Subject: Injecting Tapestry Services into Spring beans
To: "Tapestry users" <us...@tapestry.apache.org>
Received: Tuesday, October 5, 2010, 1:25 PM

Would someone please enlighten me on how to achieve this? Tapestry 5.1 release notes state that "Tapestry Services can now be injected into Spring Beans, when using the Tapestry/Spring integration library."
Integration of spring beans into tapestry pages works fine, but injecting Tapestry services into spring beans only gives me a null object. 

I read a mailing list thread where one user had succeeded in this by using Spring's <context:component-scan> and then @autowired on the beans, but when I tried this I got errors "No service implements the interface org.apache.tapestry5.services.Session" or any other service I'm trying to inject
I have not enabled legacy mode in my web.xml. Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">
 <display-name>My App</display-name>
    <context-param>
        <!--
            The only significant configuration for Tapestry 5, this informs
            Tapestry of where to look for pages, components and mixins.
        -->
        <param-name>tapestry.app-package</param-name>
     <param-value>ca.my.app</param-value>
    </context-param>
    <context-param>
 
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml /WEB-INF/securityContext.xml</param-value>
    </context-param>
 
    <filter>
     <filter-name>HibernateFilter</filter-name>
        <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
        <init-param>
            <param-name>sessionFactoryBeanName</param-name>
            <param-value>assessmentSessionFactory</param-value>
        </init-param>
    </filter>
    <filter-mapping>
     <filter-name>HibernateFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    <filter>
        <filter-name>app</filter-name>
        <!--
            Special filter that adds in a T5 IoC module derived from the Spring
            WebApplicationContext.
        -->
        <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/*</url-pattern>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>REQUEST</dispatcher>
 </filter-mapping>

</web-app>

I would really appreciate if someone could give me a heads up on where my problem might be. 
Thanks.







Injecting Tapestry Services into Spring beans

Posted by Jeshurun Daniel <sj...@yahoo.ca>.
Would someone please enlighten me on how to achieve this? Tapestry 5.1 release notes state that "Tapestry Services can now be injected into Spring Beans, when using the Tapestry/Spring integration library."
Integration of spring beans into tapestry pages works fine, but injecting Tapestry services into spring beans only gives me a null object. 

I read a mailing list thread where one user had succeeded in this by using Spring's <context:component-scan> and then @autowired on the beans, but when I tried this I got errors "No service implements the interface org.apache.tapestry5.services.Session" or any other service I'm trying to inject
I have not enabled legacy mode in my web.xml. Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
	version="2.4">
 <display-name>My App</display-name>
	<context-param>
		<!--
			The only significant configuration for Tapestry 5, this informs
			Tapestry of where to look for pages, components and mixins.
		-->
		<param-name>tapestry.app-package</param-name>
 	<param-value>ca.my.app</param-value>
	</context-param>
	<context-param>
 
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/daoContext.xml /WEB-INF/applicationContext.xml /WEB-INF/securityContext.xml</param-value>
	</context-param>
 
	<filter>
 	<filter-name>HibernateFilter</filter-name>
		<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
		<init-param>
			<param-name>sessionFactoryBeanName</param-name>
			<param-value>assessmentSessionFactory</param-value>
		</init-param>
	</filter>
	<filter-mapping>
 	<filter-name>HibernateFilter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
	<filter>
		<filter-name>app</filter-name>
		<!--
			Special filter that adds in a T5 IoC module derived from the Spring
			WebApplicationContext.
		-->
		<filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
	</filter>

	<filter-mapping>
		<filter-name>app</filter-name>
		<url-pattern>/*</url-pattern>
		<dispatcher>FORWARD</dispatcher>
		<dispatcher>REQUEST</dispatcher>
 </filter-mapping>

</web-app>

I would really appreciate if someone could give me a heads up on where my problem might be. 
Thanks.





Re: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by iberck <ib...@gmail.com>.
Thank you Howard, Thank you Thiago
 
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3199978.html
Sent from the Tapestry - User 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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by Howard Lewis Ship <hl...@gmail.com>.
My Tapx library includes a component that reads an external template
file (as XML) and can render it as part of a Tapestry page, including
delegating parts of it to blocks, and processing expansions.

Documentation coming (but lower priority than T5.2 docs, so be patient).

On Tue, Oct 5, 2010 at 4:18 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Tue, 05 Oct 2010 07:46:22 -0300, iberck <ib...@gmail.com> wrote:
>
>> But I have another question?
>> From this principle of static structure dynamic behaviour, can I create
>> with T5 a CRM based on plugins like drupal/jomla ?
>
> Yes. I can think of two approaches:
>
> 1) Override or advise the Tapestry template loading service, so users can
> edit templates.
>
> 2) (Strongly preferred) Use some templating engine like Freemarker to let
> the users edit content and Tapestry for anything else. Tapestry templates
> were always meant to be used by developers only, not end users, while
> Freemarker and similar tools are way more suited for this task. Search the
> mailing list for CMS for more discussions about this.
>
> --
> 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
>
>



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


Re: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 05 Oct 2010 07:46:22 -0300, iberck <ib...@gmail.com> wrote:

> But I have another question?
> From this principle of static structure dynamic behaviour, can I create  
> with T5 a CRM based on plugins like drupal/jomla ?

Yes. I can think of two approaches:

1) Override or advise the Tapestry template loading service, so users can  
edit templates.

2) (Strongly preferred) Use some templating engine like Freemarker to let  
the users edit content and Tapestry for anything else. Tapestry templates  
were always meant to be used by developers only, not end users, while  
Freemarker and similar tools are way more suited for this task. Search the  
mailing list for CMS for more discussions about this.

-- 
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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by iberck <ib...@gmail.com>.
Thank you all for your answers
The concept is more clear for me...

But I have another question?
>From this principle of static structure dynamic behaviour, can I create with
T5 a CRM based on plugins like drupal/jomla ?

Thanks in advance
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3199239.html
Sent from the Tapestry - User 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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by iberck <ib...@gmail.com>.
terrific response
Thank you very much

-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3198975.html
Sent from the Tapestry - User 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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by Christophe Cordenier <ch...@gmail.com>.
Hi

Actually, there is no problem if you do that since you generate a
valid action URL of your form and use request service to read
parameter values.

But this is not how Tapestry has been designed, Tapestry is a
component oriented framework, not an action oriented framework. Static
structure simply means that you cannot create *new* instances of
component at runtime. That does not mean that you as a developer can't
go beyond this principle and use Request.getParameter() method or even
generate plain HTML in dom tree

But if you use Tapestry components, you must be aware that even if you
put a component inside a loop, the inner component will be 'rendered'
n-times but ultimately there is only ONE instance of this component.

2010/10/5 iberck <ib...@gmail.com>:
>
> Hi, thank you for the response
>
> So I don't understand the principle
>
> 1. What happend if I add a html element in the tree dom and I get the value
> from the request after submit ?
> I'm violating the principle?
>
> Is there a problem if I do that?
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3198857.html
> Sent from the Tapestry - User 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,
Christophe Cordenier.

Committer on Apache Tapestry 5
Co-creator of wooki @wookicentral.com

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


Re: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by iberck <ib...@gmail.com>.
Hi, thank you for the response

So I don't understand the principle

1. What happend if I add a html element in the tree dom and I get the value
from the request after submit ? 
I'm violating the principle?

Is there a problem if I do that?


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3198857.html
Sent from the Tapestry - User 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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Mon, 04 Oct 2010 17:29:36 -0300, iberck <ib...@gmail.com> wrote:

> Hi forum,

Hi!

> I have a question,
> since T5.2 does't use a pages pool, what happend with Tapestry principle  
> 1?

It stays the same. The difference is that there's only one instance for  
every page.

> Now, can we have a more flexible component framework? :)

We have a very flexible component framework. :) You only need to think  
some scenarios in a little different way.

-- 
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: [T5.2] Principle 1, Static Structure Dynamic Behaviour

Posted by Josh Canfield <jo...@gmail.com>.
The documentation is in flux, but I actually just re-wrote that
section of the docs... feedback is welcome.

https://cwiki.apache.org/confluence/display/TAPESTRY/Principles

Static structure referred to page pooling a lot, but it's really more than that.

Josh

On Mon, Oct 4, 2010 at 1:29 PM, iberck <ib...@gmail.com> wrote:
>
> Hi forum,
>
> I have a question,
>
> since T5.2 does't use a pages pool, what happend with Tapestry principle 1?
> Now, can we have a more flexible component framework? :)
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-2-Principle-1-Static-Structure-Dynamic-Behaviour-tp3198357p3198357.html
> Sent from the Tapestry - User 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
>
>



-- 
--
http://www.bodylabgym.com - a private, by appointment only, one-on-one
health and fitness facility.
--
http://www.ectransition.com - Quality Electronic Cigarettes at a
reasonable price!
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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