AJAX updating table row
Hey! Always more questions! I'm following this example: Ajax EventLinks in a Loop http://jumpstart.doublenegative.com.au/jumpstart/examples/ajax/eventlinksinaloop . I've modified some code to fit my use case. I have a table that uses a t:loop to iterate through services and show if they are activated. I then have eventlinks to activate/deactivate services. My server code writes to a database based on the eventlink clicked. Here are parts of the code (dunno how to post html): t:loop t:source = services t:value = service (tr) t:type = Zone t:id = rowZone id = currentRowZoneId t:update = show (td)${service.name}(/td) (a) t:type = eventlink t:event = deactivate t:context = service.serviceID t:zone = ^ href = #Deactivate(/a) My java: private ListService services; @InjectComponent private Zone rowZone; @Inject private Request request; @Inject private AjaxResponseRenderer ajaxResponseRenderer; @Property private Service service; void setupRender() { services = getServices(); } public boolean getIsActivated() { User u = getUser(); for (UserService us : u.getUserServices()) { if (us.getService().getServiceID() == service.getServiceID()) return true; } return false; } public ListService getServices() { if (services == null) { services = serviceDao.findAll(); } return services; } public void onDeactivate(Long serviceID) { UserService us = userServiceDao.findByUserIdAndServiceId(currentUserID, serviceID); userServiceDao.delete(us.getUserserviceID()); if (request.isXHR()) { ajaxResponseRenderer.addRender(rowZone); } } public String getCurrentRowZoneId() { return rowZone_ + service.getServiceID(); } So when the eventlink is clicked, the onDeactivate() method gets called with serviceID as context. This removes the userservice from the db and calls addRender() on the rowZone. I immediately get this error: Render queue error in Expansion[PropBinding[expansion service/ActivationAjax(service.name)]]: Property 'service' (within property expression 'service.name', of org.synchronica.example.pages.service.ServiceActivationAjax@53e1b8fb) is null. Since ajax is only making the specific row to update, we aren't looping again so how does it know which service (thus NPE)? In the tutorial I posted above, it works fine. Any ideas? -- View this message in context: http://tapestry.1045711.n5.nabble.com/AJAX-updating-table-row-tp5718433.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
[5.3.6] Loop component giving coercion error
I've been reading other posts but nothing seems to work for me. Here's my page: public class ServiceActivation { private ListUser users; @Property private UserService userservice; @Property private User u; @Inject private UserDao userDao; public ListUser getUsers() { if (users == null) { users = userDao.findAll(); } return users; } public void onSuccess(UserService userservice) { System.out.println(userservice); } } A user has a ListUserService that gets loaded at userDao.findAll() along with the User. I have a form that I want to loop through all the users and give them an option to 'activate' a service, contained in the userservice object. I'm just posting the nested loops because I can't format the whole thing nicely, but it's within a form and there is a sbumit button for each nested iteration: t:loop source = users value = u formState = none t:loop source = ${u.userServices} value = userservice formState = none /t:loop /t:loop Inside both loops I try to access properties of u and userservice. I get this error message: Render queue error in BeginRender[service/Activation:loop_0]: Failure writing parameter 'value' of component service/Activation:loop_0: Could not find a coercion from type java.lang.String to type org.synchronica.example.entities.userservice.UserService. I've read that formState = none does something in this case but I don't understand it. There's also the ValueEncoder I don't understand, but I don't want to make a database call for each item in the list (if that's the way to implement it). -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Loop-component-giving-coercion-error-tp5718395.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: [5.3.6] Loop component giving coercion error
Yes, that did it. God damn it's been bugging me for two hours trying to find solutions. I think I had switched it because something had previously caused an exception and I thought I needed the expansion. Can you explain the use of formState and encoder in the form component? I don't quite get the docs. -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Loop-component-giving-coercion-error-tp5718395p5718397.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: [5.3.6] Loop component giving coercion error
Hey So it worked as you said, but now I have another problem. Can you tell me why this isn't working? t:loop source = services values = service formState = none ${service.name} /t:loop It gives me the following error: Render queue error in Expansion[PropBinding[expansion service/Activation(service.name)]]: Property 'service' (within property expression 'service.name', of org.synchronica.example.pages.service.ServiceActivation@29b65ab8) is null. I have properties for both 'services' and 'service'. A service has a name attribute with a getter. -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Loop-component-giving-coercion-error-tp5718395p5718400.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: [5.3.6] Loop component giving coercion error
I need sleep. Thanks! -- View this message in context: http://tapestry.1045711.n5.nabble.com/5-3-6-Loop-component-giving-coercion-error-tp5718395p5718403.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
While we are on the subject. @CommitAfter commits the transaction after the called method. What if I call multiple methods annotated with @CommitAfter? The commits happen after each of them. If I reach a method where an Exception is raised and I need to rollback, will it rollback every transaction performed on the session? I'm assuming no. How do you manage that? -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718406.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
More questions: I have an onSuccess() method in my Page class that calls a DAO delete method annotated with @CommitAfter. When the onSuccess() gets called (I'm using a form with a submit) the delete doesn't get commit at the end of the request (although I see hibernate log it). If I annotate the onSuccess() method with @CommitAfter, then the delete is commit and the entity is no longer in my db. Is this what you meant by doesn't support nesting? What is up? -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718407.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
Answer my question too. I read that little bit you linked and I understand the HibernateTransactionAdvisor does it for you. -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718408.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
@CommitAfter not committing my transaction
Unless I'm understanding it wrong, the @CommitAfter on my method isn't committing the transaction. @CommitAfter public void call() { Session s = HibernateUtils.getSessionFactory().openSession(); s.beginTransaction(); User u = new User(); u.setUsername(Pillar); u.setEmail(yahoo...@yahoo.ca); u.setPassword(poof); s.save(u); } Once execution exits this method and my page is rendered, I check my database and there is no entry for the above user. I'm on Tapestry 5.3 and have all the dependencies for tapestry-hibernate. What am I doing wrong? -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: @CommitAfter not committing my transaction
It is in a Controller. If it was in DAO Layer, do I still use the @Inject for a session or get it from HibernateUtils style class? Now regardless of if I get the Transaction from the Session I'm given from the SessionFactory, shouldn't Tapestry be finding the same Transaction and committing it? -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718367.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
As far as I know a Hibernate Session has only one Transaction at a time, hence the session.beginTransaction, session.getTransaction(). Also, the SessionFactory has the getCurrentSession() which returns a per thread session. So unless, I'm completely wrong in how I think tapestry-hibernate is implemented, it shouldn't have to much hard time finding the session from the SessionFactory, either starting the transaction itself or not, and then getting the transaction from the session and committing it. -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718374.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
I'm not in a position to test it right now, so I won't say if it worked. Where does Tapestry get that session for you? But you are right, that is smarter/better than popping out your own every time. -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718377.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: @CommitAfter not committing my transaction
Ok, so I didn't know that, I thought SessionFactory was a singleton. I will use Tapestry-Hibernate the way it's meant to just like in the link you posted. Thanks! -- View this message in context: http://tapestry.1045711.n5.nabble.com/CommitAfter-not-committing-my-transaction-tp5718364p5718380.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
SessionState
Hi, In the Tapestry User Guide for session storage http://tapestry.apache.org/session-storage.html , it states Any other component or page that declares a field of the same type, regardless of name, and marks it with the SessionState annotation will share the same value. I have the following Page class: public class Page { @SessionState private User loggedInUser; @SessionState private User buddy; } Am I understanding correctly that both of these instances of User will be the same? And that if I want them to be different, I have to encapsulate them in another class, add an instance variable of that class to my Page class, and annotate it as SessionState? Or are there other alternatives (not necessarily for this use case, just having two instances of the same type in session)? -- View this message in context: http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: SessionState
I don't know if it's common practice to send thank you's in a mailing list, but screw it. Thanks! I'm pretty sure I'll be using much more of Tapestry in the future. Sotirios Date: Mon, 26 Nov 2012 13:08:55 -0800 From: ml-node+s1045711n5718303...@n5.nabble.com To: sotodel...@hotmail.com Subject: Re: SessionState On Mon, 26 Nov 2012 18:45:14 -0200, Pillar [hidden email] wrote: Hi, Hi! In the Tapestry User Guide for session storage http://tapestry.apache.org/session-storage.html , it states Any other component or page that declares a field of the same type, regardless of name, and marks it with the SessionState annotation will share the same value. I have the following Page class: public class Page { @SessionState private User loggedInUser; @SessionState private User buddy; } Am I understanding correctly that both of these instances of User will be the same? Exactly the same. The actual name of the session attribute (which you should consider completely irrelevant) is based on the fully-qualified class name. The field name is ignored. And that if I want them to be different, I have to encapsulate them in another class, add an instance variable of that class to my Page class, and annotate it as SessionState? Yep. Or just create another class, for example, UserState, with two different fields, loggedInUser and buddy, and don't have an User in the @SessionState directly, so you have a single place for looking for the current logged in user. I've been working with Tapestry 5 since the first alphas. @SessionState works exactly in the same way since then, almost 5 years ago. I've *never* needed two different instances of the same class in the session. -- Thiago H. de Paula Figueiredo - To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] If you reply to this email, your message will be added to the discussion below: http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302p5718303.html To unsubscribe from SessionState, click here. NAML -- View this message in context: http://tapestry.1045711.n5.nabble.com/SessionState-tp5718302p5718304.html Sent from the Tapestry - User mailing list archive at Nabble.com.