You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Martin Papy (JIRA)" <de...@tapestry.apache.org> on 2008/07/10 20:12:31 UTC

[jira] Created: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

@Persist should allow to persist data not only between request, but also when submitting a form or making actions
-----------------------------------------------------------------------------------------------------------------

                 Key: TAPESTRY-2512
                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
             Project: Tapestry
          Issue Type: Improvement
          Components: Annotations
    Affects Versions: 5.0.13
            Reporter: Martin Papy


If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.

I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)

Ex :

1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
2 - Update my values and post the form
3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
4 - use onSuccess to do a Merge and a Commit :)

Code exemple :

public class UserEditor {
	@Parameter(required=true)
	@Property
	@Persist
	private User _user;
	
	@Inject
	private UserManager _userManager;
	
	protected void onSuccess() {
		//Save the Profile Update
		_userManager.merge(_user);
		_userManager.commit();
	}
}

Associated template

<t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Martin Papy (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612798#action_12612798 ] 

Martin Papy commented on TAPESTRY-2512:
---------------------------------------

Ho... After you response (thank you for it) I finally  managed to find out why my Persistent object was null on Submit...

This is because I try to Persist a Parameter field. I think it is mutually exclusive... May be it should raise an Error/Warning ?

The following code works -is there a better way to do this ?- :

Code :

public class UserEditor {
@Parameter(required=true)
private User _user;

@Persist
@Property
private User _editableUser;

@Inject
private UserManager _userManager;

protected void onPrepare() {
	if(_editableUser== null) {
		_editableUser= _user;
	}
}

protected void onSuccess() {
	//Save the Profile Update
	_userManager.merge(_user);
	_userManager.commit();
}
}

Associated template

<t:beanEditForm t:object="editableUser" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" /> 

> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Martin Papy (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612798#action_12612798 ] 

kheldar666 edited comment on TAPESTRY-2512 at 7/11/08 1:17 AM:
----------------------------------------------------------------

Ho... After you response (thank you for it) I finally  managed to find out why my Persistent object was null on Submit...

This is because I try to Persist a Parameter field. I think it is mutually exclusive... May be it should raise an Error/Warning ?

The following code works -is there a better way to do this ?- :

Code :

public class UserEditor {
@Parameter(required=true)
private User _user;

@Persist
@Property
private User _editableUser;

@Inject
private UserManager _userManager;

@SetupRender
protected void onSetupRender() {
	_editableContent = _htmlContent;
}

protected void onSuccess() {
	//Save the Profile Update
	_userManager.merge(_user);
	_userManager.commit();
}
}

Associated template

<t:beanEditForm t:object="editableUser" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" /> 

      was (Author: kheldar666):
    Ho... After you response (thank you for it) I finally  managed to find out why my Persistent object was null on Submit...

This is because I try to Persist a Parameter field. I think it is mutually exclusive... May be it should raise an Error/Warning ?

The following code works -is there a better way to do this ?- :

Code :

public class UserEditor {
@Parameter(required=true)
private User _user;

@Persist
@Property
private User _editableUser;

@Inject
private UserManager _userManager;

protected void onPrepare() {
	if(_editableUser== null) {
		_editableUser= _user;
	}
}

protected void onSuccess() {
	//Save the Profile Update
	_userManager.merge(_user);
	_userManager.commit();
}
}

Associated template

<t:beanEditForm t:object="editableUser" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" /> 
  
> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612605#action_12612605 ] 

Howard M. Lewis Ship commented on TAPESTRY-2512:
------------------------------------------------

Uh ... this is what Tapestry does today.

If you use BeanEditForm on a property that is persistent, it will quite happily use the persisted value rather than create a new one.  It only creates a new instance when the object parameter is null.

Hibernate complicates things a bit, because if you use @Persist("entity"), what gets stored in the HttpSession is the entity name and primary key, not the object itself.  If you don't like this, it is quite possible to create your own persistence strategy that, for example, detaches and stores the object into the session and merges it back into the session on later requests.

The logic for saving and restoring persistent field values is agnostic (or unaware) of whether a request is a page render, a component action, or an Ajax-related request.

I'll need more details about your issue, or I'll be closing this as "invalid".

> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Commented: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Martin Papy (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612602#action_12612602 ] 

Martin Papy commented on TAPESTRY-2512:
---------------------------------------

You have this exact behavior if you use a @ApplicationState but I think it is not a good idea to use ApplicationState in that case.

> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Issue Comment Edited: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Martin Papy (JIRA)" <de...@tapestry.apache.org>.
    [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12612602#action_12612602 ] 

kheldar666 edited comment on TAPESTRY-2512 at 7/10/08 11:16 AM:
-----------------------------------------------------------------

You have this exact behavior if you use a @ApplicationState instead of the @Persist but I think it is not a good idea to use ApplicationState in that case.

      was (Author: kheldar666):
    You have this exact behavior if you use a @ApplicationState but I think it is not a good idea to use ApplicationState in that case.
  
> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


[jira] Closed: (TAPESTRY-2512) @Persist should allow to persist data not only between request, but also when submitting a form or making actions

Posted by "Howard M. Lewis Ship (JIRA)" <de...@tapestry.apache.org>.
     [ https://issues.apache.org/jira/browse/TAPESTRY-2512?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Howard M. Lewis Ship closed TAPESTRY-2512.
------------------------------------------

    Resolution: Invalid
      Assignee: Howard M. Lewis Ship

Yes, typically you make a field persistent and then bind the parameter to the persisted field.

> @Persist should allow to persist data not only between request, but also when submitting a form or making actions
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: TAPESTRY-2512
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2512
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Annotations
>    Affects Versions: 5.0.13
>            Reporter: Martin Papy
>            Assignee: Howard M. Lewis Ship
>
> If you use @Persist on on Component property the value is kept between 2 request, but not when submitting a Form for instance.
> I think it would be very useful / powerful -particularly with Hibernate- to give access to the Persisted value even when a when a Form is submitted (if it is possible...)
> Ex :
> 1 - Get my instance of a User from Hibernate and display it with the BeanEditForm and use @Persist on it
> 2 - Update my values and post the form
> 3 - My instance of user would be directly update (because the BeanEditForm would use the persisted value and not a freshly created one)
> 4 - use onSuccess to do a Merge and a Commit :)
> Code exemple :
> public class UserEditor {
> 	@Parameter(required=true)
> 	@Property
> 	@Persist
> 	private User _user;
> 	
> 	@Inject
> 	private UserManager _userManager;
> 	
> 	protected void onSuccess() {
> 		//Save the Profile Update
> 		_userManager.merge(_user);
> 		_userManager.commit();
> 	}
> }
> Associated template
> <t:beanEditForm t:object="user" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" />

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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