I'm developing a web application using stripesframework and had an issue. I found a work around but I want to know why it was happening.
I wrote a class like
@UrlBinding("/subject/{subject_type}/{subject_name}")
public class SubjectActionBean extends ActionBean {
private String subjectType;
private String subjectName;
@Validate(required = true)
public void setSubjectName(String subjectName) {
this.subjectName = subjectName;
}
@Validate(required = true)
public void setSubjectType(String subjectType) {
this.subjectType = subjectType;
}
@DefaultHandler
public Resolution view() {
return new Resolution();
}
}
where subject_type and subject_name change based on the subject page from which the action was called. So a call would be localhost/subject/applied/math.
Till here it was working fine. The problem happened when I tried to create a remove method
@HandlesEvent("remove")
public void removeSubject() {
}
and called it using localhost/subject/applied/math/remove At this point stripes started complaining that there is no handler to the call and there is also no default handler.
So, I removed "{subject_type}/{subject_name}" in the path and passed them as parameters and inside the method unpacked them using:
getContext().getRequest().getParameter();
This made the remove method to get called.
My question now why "{subject_type}/{subject_name}" made stripes unable to find the remove method.
Try changing the @UrlBinding
to the following:
@UrlBinding("/subject/{subject_type}/{subject_name}/{$event}")
Without the {$event}
Stripes is not able tell which part of the URL parameter is supposed to be the event.
Also, to test you can try (with the current @UrlBinding
) to access localhost/subject/applied/math?remove=
Hope that helps.