Something you could try is adding a property called "formatType" in
your table bean. Implement the setFormatType method to create an instance
of the appropriate formatter and store it in the bean as another property
called "formatter".
Then, the graphics designer can use the following tags:
<usebean name="dynamicTable" type="com.mypackage.TableBean">
<setoncreate beanproperty="formatType" value="currency">
<setoncreate beanproperty="formatter.decimals" value="2">
</usebean>
I'm assuming that you can use sub-properties in the <setoncreate>
tag - I admit I haven't actually tried it. Anyone think of another
solution?
Cheers,
Greg.
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kurt Williams
> Sent: Friday, March 05, 1999 10:45 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Another JSP 1 spec suggestion
>
>
> Actually, that's what I'm doing right now. My JSP pages make all of
> their requests through a servlet, which populates the
> session/application with beans that the target JSP page will use. The
> problem with this approach is that my "interaction controller" servlet
> can't anticipate every possible type of page request. For example, I
> have several "text format" beans that do all kinds of nifty formatting.
> I also have a table bean that takes data from my collection beans and
> creates dynamic tables. I would like to be able to have my page-layout
> people be able to use my format beans in conjunction with the table
> bean. It would be great to be able to setup a column's format to use an
> already-instantiated format bean. For example:
>
> <usebean name="currencyFormat" type="com.mypackage.CurrencyFormatBean">
> <setoncreate beanproperty="decimals" value="2">
> </usebean>
>
> <usebean name="dynamicTable" type="com.mypackage.TableBean">
> <setfrombean beanproperty="columnFormat" value="currencyFormat">
> </usebean>
>
> Note the use of my suggested <setfrombean> tag. It allows you to
> reference annother bean and use it to set a property. True, I could
> create a servlet that sets all of this up, but I don't want my graphic
> designers to have to toddle over to me every time they want to set
> things up differently. This type of thing should be able to be set up
> in the JSP file.
>
> - Kurt
>
> > -----Original Message-----
> > From: Greg Dinning [SMTP:[EMAIL PROTECTED]]
> > Sent: Friday, March 05, 1999 8:34 AM
> > To: Kurt Williams; [EMAIL PROTECTED]
> > Subject: RE: Another JSP 1 spec suggestion
> >
> > If you don't want to use Java in your page, you can take a
> > different approach and use the model where the user sends a
> > request to a servlet which callPage's a JSP. Do all of your
> > processing in the servlet, and place the resulting beans into
> > the session. Then, all you have to do in your JSPs is use
> > the INSERT values of the bean properties.
> >
> > Using this approach can make life easier for your graphic
> > designers. Also, it allows them to completely change the
> > visuals of the page without having to involve a Java designer.
> >
> > Hope this helps.
> >
> > Cheers,
> > Greg.
> >
> > > -----Original Message-----
> > > From: A mailing list about Java Server Pages specification and
> > reference
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Kurt Williams
> > > Sent: Thursday, March 04, 1999 11:51 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: Another JSP 1 spec suggestion
> > >
> > >
> > > BTW (and to save time...), yes, I already know that I can always
> > break
> > > into Java with:
> > >
> > > <% tableBean.setColumnFormat = dataFormatBean; %>
> > >
> > > The idea is to avoid Java coding so that my page building folks
> > don't
> > > have to know any java ;)
> > >
> > > - Kurt W.
> > >
> > > > -----Original Message-----
> > > > From: Kurt Williams [SMTP:[EMAIL PROTECTED]]
> > > > Sent: Thursday, March 04, 1999 9:39 AM
> > > > To: [EMAIL PROTECTED]
> > > > Subject: Another JSP 1 spec suggestion
> > > >
> > > > After using JSP for a while (and loving it) I've ran into a number
> > of
> > > > situations where it would be advantageous to be able to set a
> > bean's
> > > > property to another bean. For example, I've got a set of format
> > beans
> > > > and I've got a table bean. It would be nice to assign the
> > > > table.columnFormat property to a bean, rather than a string.
> > Right
> > > > now
> > > > it seems that we are limited to just setting/getting string
> > > > properties.
> > > > It seems there should be some way to set a bean's property to
> > another
> > > > bean, not just a string.
> > > >
> > > > Something like a <SETFROMBEAN> tag that could work like:
> > > >
> > > > <USEBEAN name="dateFormatBean"
> > > > type="com.mypackage.DateFormatBean"></BEAN>
> > > >
> > > > <USEBEAN name="tableBean" type="com.mypackage.TableBean">
> > > > <SETFROMBEAN BEANPROPERTY="columnFormat" VALUE="dateFormatBean">
> > > > </USEBEAN>
> > > >
> > > > This would be ultra cool and very useful. If there's already some
> > way
> > > > to do this, someone let me know.
> > > >
> > > > Thanks!
> > > >
> > > > _______________________________
> > > > Kurtis G. Williams
> > > > Internet Applications Development
> > > > Sterling Wentworth Corp.
> > > > [EMAIL PROTECTED]
> > > > phone: (801) 355-9777 x260
> > > > fax: (801) 355-9792
> > > >
> > > >
> > ======================================================================
> > > > =====
> > > > To unsubscribe, send email to [EMAIL PROTECTED] and include in
> > the
> > > > body
> > > > of the message "signoff JSP-INTEREST". For general help, send
> > email
> > > > to
> > > > [EMAIL PROTECTED] and include in the body of the message
> > "help".
> > >
> > > ==================================================================
> > > =========
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include
> > > in the body
> > > of the message "signoff JSP-INTEREST". For general help, send email
> > to
> > > [EMAIL PROTECTED] and include in the body of the message "help".
> > >
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff JSP-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".