For something like this I would do it this way: -) Write out your html as you would normally...
-) For all messages define one basic css class name and set it on all of them. -) Create a more specific css class name for each message type. -) Create a simple method that returns a String of the css classes to apply to your html element , depending on the type of message... IE : Html: <div jwcid="@Any" class="ognl:messageTypeClass" >Stuff</div> java component: public String getMessageTypeClass() { StringBuffer str = new StringBuffer("message"); switch(getMessageType()){ case Message.WARNING: str.append(" warning"); break; case Message.INFO: str.append(" info"); break; // etc... } } That's it. Then make sure you clearly document what the class names are, but don't define them. The second you output a style="" or embed a <style> definition you remove any ability anyone else has to control the styling on your html. If you are using tapestry 4.1.1 I think Andy recently added in the ability to have components/libraries contribute css files directly to a document but I haven't used / investigated its usage yet.. On 10/30/06, Daniel Tabuenca <[EMAIL PROTECTED]> wrote:
Why not use a paraamter on the MessagePane component? You can then use an @If component in your MessagePane to render the css differently depending on the value of the parameter. Am I not understanding correctly what you are trying to do? On 10/30/06, Shaun <[EMAIL PROTECTED]> wrote: > > Hello all, > > I'm trying to determine the best way to generate slightly different output > for a component, based upon the parameters passed into it. For example, > suppose I've created a component called MessagePane that displays a title > and message inside of some CSS formatting: > > <span jwcid="@MessagePane" title="Unread Messages" message="You have 6 > unread messages.">Unread Messages</span> > > Depending upon the type of message being displayed, I'd like to change the > CSS class of the object... Say, a generic alert might appear in a pane with > a light blue border, but a critical error should be highlighted in red. The > way I've implemented this for now is that I've subclassed MessagePane as > ErrorPane, and I placed the modified CSS directly into the ErrorPane.html > template. > > Is there an easier way to accomplish this goal, preferably using a single > component? I'm now going to need several more "message types" - I'd rather > be able to pass in the type as a parameter, instead of creating a new > subclassed component for each type. > > Thanks! > -- > View this message in context: http://www.nabble.com/One-component%2C-multiple-templates--tf2541643.html#a7081573 > Sent from the Tapestry - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- Jesse Kuhnert Tapestry/Dojo/(and a dash of TestNG), team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com