views:

483

answers:

1

Im working on a groovy on grails conference management system which was written by a student temp a few months ago. Unfortunately theres only a very poor documentation and the style of programming is not that nice (check out the comments)...

well, heres the problem: there is a domain class "participant" - within the view there is a possibility to select some filters. Those filters get applied through the corresponding controller. Once the filter has been applied to the selection, the result gets posted. Now the problem is, that I dont know how to revert those filters or clear them. Obviously a simple HTML reset button within the view won't work as the filtered result gets posted.

Could anyone tell me, how to clear the filters used? Obviously, I dont want a hardcoeded href which redirects the user to the normal "list" action. Any idea(s)?

+4  A: 

There are many ways to do what (I think) you want to do. One idea is to create another action in the same controller as the filter action that returns the list you want. I could try to give you an example but from the code you posted it isn't clear which view you're coming from, which view should be shown after clearing the filter or where the hardcoded id (1) id coming from. Also, is it possible that the code you posted had been modified in an attempt to solve this? The getParticipants method doesn't appear to be called at all.

If you wanted to answer some of these questions: starting view, target view (after clearing filters), controller involved and where the id is coming from, I could try to give you a better answer.

Thanks for the extra info. Here's one possible solution. I didn't try this so the syntax may not be exact but it'll get you started:

It looks like what you would get without the filters is all the participants for a Conference. If that's correct then you can add an action like this to ParcipantController.groovy

def clearFilter = {
    def conference = Conference.get(params.id)
    def participants = conference.participants
    render(view:'list', model:[participants: participants, 
     participantsTotal: participants.size(),
     startDate:conference.start, 
     endDate:conference.end,
     canWrite: accessRightsService.canWrite(request.beholder, conference)])
}

Then you can add a tag to your page instead of the hard-coded anchor tag like this: Clear Filter

I hope that helps, Dave

Dave Klein
well, first of all thanks a lot for your engagement!the starting view would be the "list" of the "participant" controller (where the controller code comes from) - the listing initially works fine and there are this html table where one can select the desired filters...after having selected the filters one presses the "filter" button. the appropriate action gets executed. Do not worry about that disgusting hardcoded link :-P after the filters have been applied the result gets POSTed. As you can see from the comments, all "participants" get loaded and filtered afterwards...
Gnark
thanks again - but still no luck... Ive updated my question above!have a nice weekend!
Gnark