RE: Editing a JPA entity

2016-01-06 Thread C N Davies
Christoph I understand why this happens, I was simply asking if there was a
better way to do this using some struts session magic or such. Seems there
isn't so I'll just do it the old long winded way.


-Original Message-
From: Christoph Nenning [mailto:christoph.nenn...@lex-com.net] 
Sent: Tuesday, January 5, 2016 6:57 PM
To: Struts Users Mailing List 
Subject: Re: Editing a JPA entity

> I'm using an action to retrieve a list of entities and render these as 
> a list, the user can then select an edit button that calls an action 
> that retrieves the individual entity and renders the edit page. Once 
> the user
has
> completed editing they hit the save button which calls the action that
calls
> the entity manager's merge method to update the db. Each of these
actions
> call methods of the same action class, but the entity ends up in a
detached
> state so merge will fail. I could just retrieve the entity again and
then
> update each data member but this seems like a very messy way to do it. 
Is
> there a better way to do this with struts?
> 
> 
> 
> I'm using struts 2.3.20 with hibernate 4.3.11
> 
> 


Well, that is basic http. When data is SELECTed from DB and the html page is
rendered the server is done. That means at this point there are no more
references to attached jpa objects. In terms of http: the handling of GET
request is completed.

When the user hits save the browser issues another http request, usually a
POST request. On the server side there is no more state or information that
there has been a GET request before and entities had been loaded.

So yes, you have to retrieve the entity again and update it.



Regards,
Christoph

This Email was scanned by Sophos Anti Virus


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: unsubscribe me

2016-01-06 Thread Dave Newton
That isn't how it works.

https://struts.apache.org/mail.html

On Wed, Jan 6, 2016 at 4:22 PM, john feng  wrote:

> unsubscribe
>



-- 
e: davelnew...@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton 
b: Bucky Bits 
g: davelnewton 
so: Dave Newton 


unsubscribe me

2016-01-06 Thread john feng
unsubscribe


Re: S2: How to tell if a response has been committed from an interceptor?

2016-01-06 Thread Ken McWilliams
Well you go down the chain create the result and then back up the chain.
So when going back up the response should already be committed.

see: https://struts.apache.org/docs/writing-interceptors.html

//modified code from above link to clarify
public String intercept(ActionInvocation invocation) throws Exception {
   //do stuff before response, going down the chain
   String result = invocation.invoke();
   //do stuff after response, going back up the chain, can't do what
you seem to be trying to do here...
   return result;
}

That aside, "Cannot create a session" isn't a good message because you
shouldn't be trying to create a session at all! It's part of the containers
responsibility to do that. You just ask for it. So the real cause of the
issue might be something else.

On Wed, Jan 6, 2016 at 11:41 AM, Greg Lindholm 
wrote:

> Inside an Interceptor I'm getting an exception
>
> java.lang.IllegalStateException: Cannot create a session after the response
> has been committed
> I have access to the ActionInvocation as this is passed into doIntercept()
> public String doIntercept(ActionInvocation invocation) throws Exception
>
> My question is: from the ActionInvocation how do I find out if the response
> has been committed?
>
> Can I get the HttpServletResponse? So I can call response.isCommitted() ?
>
> How?
>
> Thanks,
> Greg
>


S2: How to tell if a response has been committed from an interceptor?

2016-01-06 Thread Greg Lindholm
Inside an Interceptor I'm getting an exception

java.lang.IllegalStateException: Cannot create a session after the response
has been committed
I have access to the ActionInvocation as this is passed into doIntercept()
public String doIntercept(ActionInvocation invocation) throws Exception

My question is: from the ActionInvocation how do I find out if the response
has been committed?

Can I get the HttpServletResponse? So I can call response.isCommitted() ?

How?

Thanks,
Greg