• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is the best way to transmit the find criteria from View to Model and to Business

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

How do you think what is the best way to transmit the find criteria from View to Model (MVC) and than to Business logic?
Transmit it as String[] or just as two values :String name, String location? (URLyBird)
From View to Model it will be sure just two String (return nameTextField.getText(), return locationTextField.getText()).
Because IMHO it's not a good idea to write some logic in the view that creates the String[] array. But I am not sure

But what about the busines logic? What is the best way to pass the find criteria to server?

Your reply will be very much appreciated!
Olena
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Olena,

Your view is possibly using a table model, and the table model possibly contains the record number - in which case I would only be passing the record number and customer number back to the model.

If you are not storing the record number anywhere, it could make life difficult when you try to do the update.

Regards, Andrew
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Andrew,

Thanks a lot for your answer.
I do store the record number on the client: my server transmits an Array of my Records object. Every Record-Object has one recordNumber field where I store the record number.
After the user called the book-method, my update method transmits the record number and the owner to server. Am I right?

But my question was about how to avoid the hardcoding of the field�s indexes and how is efficient to define my find method. I read all records information with DataSchema, I don�t store it static.

But I need to store somewhere the indexes of name, location, owner and the deletion fields. From another side I try to avoid hardcoding. Therefore I am thinking about not to store any field�s indexes in the code but store it in the properties file and read it from the file only on the server. If the Database structure or the sequence order of the field is changed, the program shouldn�t be recompiled. I need to change the indexes only in the properties file and restart the server.
I have defined a find-Method in DataClient that will be called from the client to perform the find functionality:


My client communicates with the server with this DataClient (DataAdaptorRemote implement DataClient; I use Connection Factory).
But using my idea to handle the indexes on the server I cannot implement this method in the DataClient in this form:
find(String[] criteria)
I cannot make this because my client doesn�t know the index of the name and the index of the location. That means I cannot create the criteria on the client in this form:
String[] criteria = {selectedNameForSearch, selectedLocationForSearch, null, null, null�};
And pass this to the server (in DataClient define the findByCriteria(String[] criteria)).

And my idea is to pass only the name and location (this values from the textFields) to the server as two Strings to perform the find functionality. And the server will generate the criteria in the String[] form. Because only the server knows the indexes of the name and location (which are stored in the properities file).
And my question is. Is this idea correct?
Store the indexes in properties file, pass to the server only two Strings (name and location) and than generate the search-criteria on the server? (I have 3-tier architercture)
In other words to implement the DataClient in this way that I showed above.


Please let me know if you don�t understand what I mean (My English isn�t very good). If not, I will try to rephrase my question and idea.

Thanks a lot for your attention and help!
Olena
[ April 05, 2005: Message edited by: Olena Golub ]
 
Andrew Monkhouse
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Olena,

After the user called the book-method, my update method transmits the record number and the owner to server. Am I right?



Correct.

But I need to store somewhere the indexes of name, location, owner and the deletion fields. From another side I try to avoid hardcoding.



Personally I created some constants in my Data class for field names and indexes, then used these constants in my GUI to create my array of Strings to pass into the find function. I then explained this in both the Data class and in my choices document as being my way of handling potential future changes to database structure - change the order of fields and you only have to change the constants in the Data class.

Does this give you some hints?

Regards, Andrew
[ April 05, 2005: Message edited by: Andrew Monkhouse ]
 
Olena Golub
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Andrew,
Thanks a lot for your hints!
I decided to make almost the same, but implement the storing of the indexes as a constand and create the criteria array on the server-side.
I use the 3-tier architecture and I think it should be also okey.
I need to bring forward many arguments in choises why I implement this and it should be Ok.
Thanks a lot for your useful help!
Olena
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic