Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Overriding an AspectJ method in a Roo Project




Hello,

I have just generated a web application with Spring Roo and would like to override a method which lets users search records
in a photo database.

Here's the Roo-generated Photo_Roo_Finder.aj code:

-----------------------------------

// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
// You may push code into the target .java compilation unit if you wish to edit any member(s).

privileged aspect Photo_Roo_Finder {

public static TypedQuery<Photo> Photo.findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike(
String slug, String budget, String project, String projectStatus) {

if (slug == null || slug.length() == 0) throw new IllegalArgumentException("The slug argument is required);
...

-----------------------------------------------

My problem with this method is that it does not let users leave some fields empty.

If I go into the Photo.java class, and rewrite the above method, Eclipse tells me that it already exists (ie, in the
.aj file).

If, on the other hand, I rename it in the Photo class, as follows

---------------------------------------------------

...
@RooJpaActiveRecord(finders = { "findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike2" })
...


public static TypedQuery<Photo> Photo.findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike2(..

String slug2 = "";

if (slug == null) || slug.length == 0) {
slug2 = "";

} else {
slug2 = slug;

}
// Do a search with slug2 as value.

--------------------------------------

The application, when run, crashes with an internal error:

-----------------------------

or.apache.tiles.impl.CannotRenderException: JSP Exception including path '/WEB-INF/views/photos/findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike.jspx'


where findPhotos....jspx is some kind of dynamically-generated jspx file (ie, it's not visible in the Eclipse Project).

-----------------------------

So how can I "override" the "findPhotosBySlugLikeAndBudgetLikeAndProjectLikeAndProjectStatusLike" method
in the Photo class?

Any help with the above issue would be much appreciated.

Philroc


Back to the top