• 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

another mvc question

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

two questions actually...

1. while reading some stuff in the j2ee blueprints i've found that the authors use a "mappings.xml" file to forward the request from the front controller servlet after it's done with the business logics execution... i don't think i've ever seen any usage of this file before. have you?

2. thinking about model and controller separation... this is actually a question for those of you beliving their desing is "clean" and all of the logics layers are clearly separated. in the majority of cases the redirection from the controller on after the business logics execution depends of the results we get from the business logics methods. to code those business methods to return strings which are actually the uris the request must be forwarded to means to mix a model with a view. so, we can return int or string which will be used as "codes" by controller for future redirection of the request. my question is how do you do it. what is your way of doing this.
thanks.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
2. while using Command pattern along MVC architecture, my servlet check the command and pass the request and resultant JSP page to the model. if there is some error while processing business logic. model changes that page to an error page and return it to the servlet or return a boolean "false" to the servlet, then servlet will forward that error page to the client or throws an exception which is caught by exception tag in web.xml.

how it sounds??
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you see, if you make your model return the path to a page, you mix it with the view. just think about it: if you wanna change the page you want your controller to send response to, you have to make changes in the model...
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no no. i have said both the things. read it carefully or may be i haven't explained clearly.

- my controller knows where to forward the client. model just changes the page when error or exception occurs.

the other option is better, and completely seperate.

- my model just throw error or exception if occurs. otherwise my controller knows where to redirect the client. if model return false then client will be directed to the error page defined in web.xml.

you have to receive something from the model, not the uri but at least exception to indicate whether operation is successful or not. isn't it??
[ October 02, 2004: Message edited by: adeel ansari ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by adeel ansari:
- my controller knows where to forward the client. model just changes the page when error or exception occurs.



you can also say here that model and controller are seperate.

if you change the controller to forward the client to some other page. then you can do it just changing the url inside controller. model doesn't care about, whatever the page is.

but model knows i have to change the page, no matter what page, to error page if error or exception occurs.
[ October 02, 2004: Message edited by: adeel ansari ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic