You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Kolesnikov, Alexander GNI" <Al...@CIGNA.com> on 2007/03/05 13:34:01 UTC

Trying to use StateObjectFactory...

Hello everyone,

I am using Tapestry 4.0.2.

I want to use an ASO with some security information in it. The
information should be obtained from HttpRequest on the ASO's creation. I
decided to use a StateObjectFactory to create such an ASO and configured
it like this:

<contribution configuration-id="tapestry.state.ApplicationObjects">
	<state-object name="security" scope="session">
		<invoke-factory
object="com.test.util.SecurityBeanFactory"/>
	</state-object>
</contribution>

Then I am trying to obtain the ASO in the page's code like this:

@InjectState("security")
public abstract SecurityBean getSecurity();

The code for the factory was more sensible, but to find a problem I left
just this:

public class SecureBeanFactory implements StateObjectFactory {

	public Object createStateObject() {
		SecurityBean sb = new SecurityBean(new TestUser(), new
TestApplication());
		return sb;
	}
}

However, I am getting an exception:

org.apache.hivemind.ApplicationRuntimeException 

Unable to construct configuration tapestry.state.ApplicationObjects:
Error: Object provider selector 'com.test.util.SecurityBeanFactory' is
not properly formatted. 

What can be wrong here?

Thanks,

Alexander

------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.  This email transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA
==============================================================================

Re: Trying to use StateObjectFactory...

Posted by Richard Kirby <rb...@capdm.com>.
Hi Alexander,

You need to define a service that you then reference in the invoke-factory:

<service-point id="SecurityBeanFactory" 
interface="org.apache.tapestry.engine.state.StateObjectFactory">
  <invoke-factory>
    <construct class="com.test.util.SecurityBeanFactory">
      <!-- Any config you need here... -->
    </construct>
  </invoke-factory>
</service-point>

<contribution configuration-id="tapestry.state.ApplicationObjects">
  <state-object name="security" scope="session".
    <invoke-factory object="service:SecurityBeanFactory" />
  </state-object>
</contribution>

Cheers

Richard

Kolesnikov, Alexander GNI wrote:
> Hello everyone,
>
> I am using Tapestry 4.0.2.
>
> I want to use an ASO with some security information in it. The
> information should be obtained from HttpRequest on the ASO's creation. I
> decided to use a StateObjectFactory to create such an ASO and configured
> it like this:
>
> <contribution configuration-id="tapestry.state.ApplicationObjects">
> 	<state-object name="security" scope="session">
> 		<invoke-factory
> object="com.test.util.SecurityBeanFactory"/>
> 	</state-object>
> </contribution>
>
> Then I am trying to obtain the ASO in the page's code like this:
>
> @InjectState("security")
> public abstract SecurityBean getSecurity();
>
> The code for the factory was more sensible, but to find a problem I left
> just this:
>
> public class SecureBeanFactory implements StateObjectFactory {
>
> 	public Object createStateObject() {
> 		SecurityBean sb = new SecurityBean(new TestUser(), new
> TestApplication());
> 		return sb;
> 	}
> }
>
> However, I am getting an exception:
>
> org.apache.hivemind.ApplicationRuntimeException 
>
> Unable to construct configuration tapestry.state.ApplicationObjects:
> Error: Object provider selector 'com.test.util.SecurityBeanFactory' is
> not properly formatted. 
>
> What can be wrong here?
>
> Thanks,
>
> Alexander
>
> ------------------------------------------------------------------------------
> CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.  This email transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA
> ==============================================================================
>
>   


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


RE: Trying to use StateObjectFactory...

Posted by Ben Dotte <bd...@widen.com>.
Hi Alexander,

The way I have done this is to make the factory a service as well.

<contribution configuration-id="tapestry.state.ApplicationObjects">
	<state-object name="security" scope="session">
		<invoke-factory object="service:MyFactory"/>
	</state-object>
</contribution>

<service-point id="MyFactory"
interface="org.apache.tapestry.engine.state.StateObjectFactory">
	<invoke-factory>
		<construct class="com.test.util.SecurityBeanFactory" />
	</invoke-factory>
</service-point>

HTH

Ben

-----Original Message-----
From: Kolesnikov, Alexander GNI [mailto:Alexander.Kolesnikov@CIGNA.com] 
Sent: Monday, March 05, 2007 6:34 AM
To: Tapestry users
Subject: Trying to use StateObjectFactory...

Hello everyone,

I am using Tapestry 4.0.2.

I want to use an ASO with some security information in it. The
information should be obtained from HttpRequest on the ASO's creation. I
decided to use a StateObjectFactory to create such an ASO and configured
it like this:

<contribution configuration-id="tapestry.state.ApplicationObjects">
	<state-object name="security" scope="session">
		<invoke-factory
object="com.test.util.SecurityBeanFactory"/>
	</state-object>
</contribution>

Then I am trying to obtain the ASO in the page's code like this:

@InjectState("security")
public abstract SecurityBean getSecurity();

The code for the factory was more sensible, but to find a problem I left
just this:

public class SecureBeanFactory implements StateObjectFactory {

	public Object createStateObject() {
		SecurityBean sb = new SecurityBean(new TestUser(), new
TestApplication());
		return sb;
	}
}

However, I am getting an exception:

org.apache.hivemind.ApplicationRuntimeException 

Unable to construct configuration tapestry.state.ApplicationObjects:
Error: Object provider selector 'com.test.util.SecurityBeanFactory' is
not properly formatted. 

What can be wrong here?

Thanks,

Alexander

------------------------------------------------------------------------
------
CONFIDENTIALITY NOTICE: If you have received this email in error, please
immediately notify the sender by e-mail at the address shown.  This
email transmission may contain confidential information.  This
information is intended only for the use of the individual(s) or entity
to whom it is intended even if addressed incorrectly.  Please delete it
from your files if you are not the intended recipient.  Thank you for
your compliance.  Copyright 2007 CIGNA
========================================================================
======

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