You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jim O'Callaghan <ji...@peritussolutions.com> on 2010/09/23 00:20:30 UTC

PropertyEditContext not available from Environment

I have a custom data type that I am displaying / updating successfully in
beanDisplays and beanEditForms, after making BeanBlockContributions for edit
and display, and also using a CustomPropertyEditor that defers
environment.pop(PropertyEditContext.class) until after rendering is
complete.  Recently I started using grids with parameters specified, to
allow editable fields for simple updates on multiple pojos.  When I try to
use my custom data type in a grid, I am running into the error:

No object of type org.apache.tapestry5.services.PropertyEditContext is
available from the Environment

. in BeginRender. This doesn't happen if I just use the display only version
of the custom data type in the grid.  Can anyone suggest some directions I
could look in to work around this?  Bit of a showstopper at the moment
unfortunately.  I'm using T.5.2.0.

 

Regards,

Jim.


RE: PropertyEditContext not available from Environment

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks for all your help Thiago.  I'm not trying to render all fields in the grid as form fields, just the one from my custom component X that's a property of bom Y, and a selection of other properties of bom Y that are plain Strings, Integers etc., which the grid handles perfectly just using t:param and input fields.  I have what I need working by creating a PropertyEditContext in the beginRender method of the custom component whenever it is being rendered as part of a grid, pushing it to the environment, and popping it in the afterRender method.  Hopefully this doesn't set off any alarm bells.

I like the idea of being able to use the overrides to achieve something similar, though it does put the onus on the developer to make the override available as a property in every page where a relevant grid occurs <I think>.  I'll have a look into it when I'm not so stretched for time.  Thanks again.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 23 September 2010 17:27
To: Tapestry users
Subject: Re: PropertyEditContext not available from Environment

On Thu, 23 Sep 2010 12:50:47 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thiago,

Hi!

> Are you saying the I can use <t:grid ... overrides="prop:xyz"> to get  
> around the problem?

Yes.

> Do I just build a list of PropertyOverrides in the page class for that,  
> and does it override all other overrides that the grid normally provides  
> by itself

Yes. You don't need a list of PropertyOverrides, just one. Grid (more  
specifically, GridCell) asks to the override if it provides a block for  
rendering the property (overrides.getOverrideBlock(blockId). If it returns  
null, it uses the BeanBlockSource service to get one.

> - I'm guessing this behavior is not what I want as I just want to affect  
> rendering for this specific field, < <t:myCustomComponent  
> value="bom.property"/>?

Use a <p:xxxCell> or <t:parameter name="xxxCell"> tag. I thought you were  
trying to render all grid cells as form fields.

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



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


Re: PropertyEditContext not available from Environment

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 23 Sep 2010 12:50:47 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thiago,

Hi!

> Are you saying the I can use <t:grid ... overrides="prop:xyz"> to get  
> around the problem?

Yes.

> Do I just build a list of PropertyOverrides in the page class for that,  
> and does it override all other overrides that the grid normally provides  
> by itself

Yes. You don't need a list of PropertyOverrides, just one. Grid (more  
specifically, GridCell) asks to the override if it provides a block for  
rendering the property (overrides.getOverrideBlock(blockId). If it returns  
null, it uses the BeanBlockSource service to get one.

> - I'm guessing this behavior is not what I want as I just want to affect  
> rendering for this specific field, < <t:myCustomComponent  
> value="bom.property"/>?

Use a <p:xxxCell> or <t:parameter name="xxxCell"> tag. I thought you were  
trying to render all grid cells as form fields.

-- 
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: PropertyEditContext not available from Environment

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thiago,

Are you saying the I can use <t:grid ... overrides="prop:xyz"> to get around the problem?  Do I just build a list of PropertyOverrides in the page class for that, and does it override all other overrides that the grid normally provides by itself - I'm guessing this behavior is not what I want as I just want to affect rendering for this specific field, < <t:myCustomComponent value="bom.property"/>?

I had started creating my own PropertyEditContext in the component used for my custom type <just in the scenario where it's used in a grid>, but was running into issues with an internal null pointer when I got to validate.render() in my component's beginRender method.

What I was trying to do was something along the lines of:

		boolean pECForGridRequired = (environment.peek(PropertyEditContext.class) == null);
		PropertyEditContext pECForGrid = null;
		if (pECForGridRequired){
			pECForGrid = createPECForGrid();
			environment.push(PropertyEditContext.class, pECForGrid);
		}

... and mimicking the way the PEC is created when the component is used in a beanEditForm. Is this approach wrong-headed?

Regards,
Jim. 

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 23 September 2010 14:11
To: Tapestry users
Subject: Re: PropertyEditContext not available from Environment

On Thu, 23 Sep 2010 09:25:14 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks Thiago.  I'll file a JIRA after I come up with a workaround.  I  
> would have thought this was a common enough use case, an editable custom  
> field in a grid.

I was talking about creating a component that does that, not using this  
functionality. :)

By the way, I just remembered about the overrides parameter in Grid.  
You'll probably don't need to create another component, just make sure the  
overrides provide the edition block instead of the viewing one. Maybe we  
could even add a PropertyOverrides implementation that implements that to  
Tapestry . . .

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



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


Re: PropertyEditContext not available from Environment

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 23 Sep 2010 09:25:14 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks Thiago.  I'll file a JIRA after I come up with a workaround.  I  
> would have thought this was a common enough use case, an editable custom  
> field in a grid.

I was talking about creating a component that does that, not using this  
functionality. :)

By the way, I just remembered about the overrides parameter in Grid.  
You'll probably don't need to create another component, just make sure the  
overrides provide the edition block instead of the viewing one. Maybe we  
could even add a PropertyOverrides implementation that implements that to  
Tapestry . . .

-- 
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: PropertyEditContext not available from Environment

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks Thiago.  I'll file a JIRA after I come up with a workaround.  I would have thought this was a common enough use case, an editable custom field in a grid.  It'll probably jump out at me when I get more familiar with the core code.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 23 September 2010 13:03
To: Tapestry users
Subject: Re: PropertyEditContext not available from Environment

On Thu, 23 Sep 2010 07:22:43 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks Thiago.  Can you clarify one last thing for me.  I had a look at  
> the sources you mentioned and am wondering if I have to create a  
> PropertyEditContext from scratch before pushing it to the environment,  
> or is there somewhere (factory / util class) I can source it from?

As far as I know, no. I haven't tried to do anything like you're doing,  
tough.

> It seems like a good bit of code to have to duplicate per custom  
> component?

Few components needs that. You can file a JIRA for this enhancement.

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



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


Re: PropertyEditContext not available from Environment

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 23 Sep 2010 07:22:43 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks Thiago.  Can you clarify one last thing for me.  I had a look at  
> the sources you mentioned and am wondering if I have to create a  
> PropertyEditContext from scratch before pushing it to the environment,  
> or is there somewhere (factory / util class) I can source it from?

As far as I know, no. I haven't tried to do anything like you're doing,  
tough.

> It seems like a good bit of code to have to duplicate per custom  
> component?

Few components needs that. You can file a JIRA for this enhancement.

-- 
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: PropertyEditContext not available from Environment

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks Thiago.  Can you clarify one last thing for me.  I had a look at the sources you mentioned and am wondering if I have to create a PropertyEditContext from scratch before pushing it to the environment, or is there somewhere (factory / util class) I can source it from?  It seems like a good bit of code to have to duplicate per custom component?

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 23 September 2010 01:44
To: Tapestry users
Subject: Re: PropertyEditContext not available from Environment

On Wed, 22 Sep 2010 19:48:08 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks for the reply Thiago. Could you give me a pointer on where / how  
> in the cycle to push and then pop the PropertyEditContext into / out of  
> the Environment, or point to any resource I could work through as an  
> example?  A bit lost on this.

The documentation for the Environment is here:  
http://tapestry.apache.org/tapestry5.1/guide/env.html. I suggest you to  
take a look at the BeanEditor and Grid sources.

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



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


Re: PropertyEditContext not available from Environment

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Sep 2010 19:48:08 -0300, Jim O'Callaghan  
<jc...@yahoo.co.uk> wrote:

> Thanks for the reply Thiago. Could you give me a pointer on where / how  
> in the cycle to push and then pop the PropertyEditContext into / out of  
> the Environment, or point to any resource I could work through as an  
> example?  A bit lost on this.

The documentation for the Environment is here:  
http://tapestry.apache.org/tapestry5.1/guide/env.html. I suggest you to  
take a look at the BeanEditor and Grid sources.

-- 
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: PropertyEditContext not available from Environment

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
Thanks for the reply Thiago. Could you give me a pointer on where / how in the cycle to push and then pop the PropertyEditContext into / out of the Environment, or point to any resource I could work through as an example?  A bit lost on this.

Regards,
Jim.

-----Original Message-----
From: Thiago H. de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Sent: 22 September 2010 23:44
To: Tapestry users
Subject: Re: PropertyEditContext not available from Environment

On Wed, 22 Sep 2010 19:20:30 -0300, Jim O'Callaghan  
<ji...@peritussolutions.com> wrote:

> No object of type org.apache.tapestry5.services.PropertyEditContext is
> available from the Environment

When you're using BeanEditor/BeanEditForm, they push the appopriate  
PropertyEditContext into the Environment. Grid pushes a  
PropertyOutputContext. You'll need to push a PropertyEditContext yourself.

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



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


Re: PropertyEditContext not available from Environment

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 22 Sep 2010 19:20:30 -0300, Jim O'Callaghan  
<ji...@peritussolutions.com> wrote:

> No object of type org.apache.tapestry5.services.PropertyEditContext is
> available from the Environment

When you're using BeanEditor/BeanEditForm, they push the appopriate  
PropertyEditContext into the Environment. Grid pushes a  
PropertyOutputContext. You'll need to push a PropertyEditContext yourself.

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