• 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

pattern suggestions?

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I working on a framework for returning HTML to a browser by retrieving XML and converting it HTML using the appropriate XSL file.
For this I'm using standard MVC type pattern.

One of the things I want to do is specify different XSL files to include based on some sort of criteria i.e. customerid,request type. Does anyone have any good ideas as to the appropriate pattern(s) to use for this scenario?

Much Thanks

Keith.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unless I'm missing something, in your case your XSL docs and the process for applying them constitute your view in MVC. Possibly what you are looking for is an implementation that lets you manage for view assets effectively. The pattern that describes the view management would depend on what framework you are using. For example Spring makes strong use of most of the GoF "creational patterns". You could probably also make an argument that it uses the service configurator pattern too; much the same could also be said for Struts.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The desciption is a little bit vague - a lot will depend on how flexible the mechanism needs to be.

Anyway, Chain Of Responsibility might be worth a look.

Can you tell us more?
 
keith doyle
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks very much guys for your feedback. Would it be possible to take a look at the following pseudo code? This is a general outline for the current implementation - I have added my concerns/thoughts at the end of the message:

Controller Servlet


Command Factory


Command Interface


A Comand Class

One of the problems is with getting the XSL, currently XSL file/path is hardcoded into the class.I would like this to be more generic and reusable.
Should this function even be in this class or should I move this out to the controller servlet?

Essentially the command will always return the same XML but the XSL to use will change based on certain business criteria- for example - the customerid and locale. What is a good technique for this? Should I code these values into hidden fields in the HTML?

Any thoughts and suggestions, criticisms would be greatly appreciated. I'm already taking a look at the patterns you guys suggested earlier!
Thanks again
Keith
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you look at frameworks like Struts or Spring, they move info like this into an external configuration file. Typically each view has multiple parameters to give the view whatever it needs in the way of specific configuration values. If you don't want to tackle that, you could use servlet init parameters in web.xml for the same thing. Not sure I would think of this in terms of a pattern so much as an implementation idiom.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic