Hello. I am just another Isis user like you, but I thought this might help:
Wicket viewer shows what you "return" in your action method, so, because you
are returning void, Wicket is showing "no results" message. Usually, you return
the thing you create or update, but you can return the parent if that's what
you want, or anything else you need, just get it in your code and return it.
For example, I have a method that adds a Deliverer that belongs to a
BusinessLocation, and after created shows the parent BusinessLocation entity
object instead of showing the Deliverer object just created (in my case, when
showing the BusinessLocation parent, the Deliverer just created shows in the
collection section, which is what I wanted, because Business have that
collection). If you adapt this code to your deletePerson method I think it can
work.
My sample code is:
@Action(
domainEvent = CreateDomainEvent.class
)
@MemberOrder(name = "deliverers",sequence = "24")
public BusinessLocation addDeliverer(
final @ParameterLayout(named="Business Location") BusinessLocation
businessLocation,
final @ParameterLayout(named="Deliverer Id") String delivererId,
final @ParameterLayout(named="First Name") String firstName,
final @ParameterLayout(named="Middle Name") @Parameter(optionality
= Optionality.OPTIONAL)String middleName,
final @ParameterLayout(named="Last Name") String lastName,
final @ParameterLayout(named="Last Name 2") @Parameter(optionality
= Optionality.OPTIONAL)String lastName2,
final @ParameterLayout(named="Contact Phone")
@Parameter(optionality = Optionality.OPTIONAL)Long contactPhone,
final @ParameterLayout(named="Delivery Phone")
@Parameter(optionality = Optionality.OPTIONAL)Long deliveryPhone,
final @ParameterLayout(named="Deliverer Picture")
@Parameter(optionality = Optionality.OPTIONAL) Blob delivererPicture
)
{
final Deliverer obj = container.newTransientInstance(Deliverer.class);
obj.setBusinessLocation(businessLocation);
obj.setDelivererId(delivererId);
obj.setFirstName(firstName);
obj.setMiddleName(middleName);
obj.setLastName(lastName);
obj.setLastName2(lastName2);
obj.setContactPhone(contactPhone);
obj.setDeliveryPhone(deliveryPhone);
obj.setDelivererPicture(delivererPicture);
obj.setCreationTime(clockService.nowAsDateTime());
container.persistIfNotAlready(obj);
return obj.getBusinessLocation();
}
If you choose to return the parent of the Person object being deleted, make
sure you get the parent before you Delete the person. Have fun!
Cesar.
-----Original Message-----
From: Y.R Tan [mailto:[email protected]]
Sent: Saturday, December 19, 2015 5:44 AM
To: users
Subject: How should we handle void and null results
Hi everyone,
When using a void action, let’s say a remove action, the user is redirected to
a page "no results". When clicking the back button in the browser the user sees
"Object not found" (since you’ve just deleted this object).
Example:
public class Person {
....
public void remove() {
...
}
}
You can return a list for example to prevent the user from being redirect to a
"No results" page, but I think it’s not the responsibility of the controllers
in the domain model. A solution could be that wicket viewer goes back one page
when encountering a deleted object. And refresh the current page when receiving
a null response or invoking a void action.
What do you guys think that is the best solution? Or do you have another view
on this situation?
Looking forward hearing from you.
Regards,
Yu Ri Tan
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus