Forwarding search criteria from the view

V

VisionSet

I have a bunch of related view classes, each displaying a database table.
Each has a generic controller (interface type) with a generic search method.
Each view class has a search function that takes text field contents and
forwards them to their respective controller's search method.

Since the nature of the search criteria changes between these classes I'm
thinking of having the controllers search method like so:

public void search(Object[] criteria);

Now the controllers are the most throwaway part of the code and are written
to serve view and model, so I can make assumptions about the exact types of
criteria...

I should have constants for the criteria array indices; is their logical
home the view classes? Certainly not the controller interface.

Is there a better way?

One option I realise is to access all the swing models from the controller
and never have to pass the actual data explicitly via the view code. I do
this for substantial models like TableModels, but for trivial textfields
this always seems to end up real clunky.

TIA
 
S

Sudsy

VisionSet wrote:
Is there a better way?

I don't know about better, but I'd probably approach the problem
differently. I'd try to have a single controller which would then
contain the logic to determine the originating page and process
accordingly. Easy enough with Struts and ActionMapping. I'd also
try to generalize the parameter processing, using the same field
names across multiple forms except in those cases where specific
fields apply to a particular form.
Such an approach might make it easier to maintain and extend the
application.
 
V

VisionSet

Sudsy said:
VisionSet wrote:


I don't know about better, but I'd probably approach the problem
differently. I'd try to have a single controller which would then
contain the logic to determine the originating page and process
accordingly. Easy enough with Struts and ActionMapping. I'd also
try to generalize the parameter processing, using the same field
names across multiple forms except in those cases where specific
fields apply to a particular form.
Such an approach might make it easier to maintain and extend the
application.

Don't know how I managed to avoid using the word 'Swing', but there you go
:)

This is a Swing app not a web interface.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top