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 List<Service> 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 List<Service> 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: [email protected]
For additional commands, e-mail: [email protected]