Re: BeanMessage Tag proposal

2001-03-20 Thread Pierre Delisle

"Craig R. McClanahan" wrote:
 I'm doing a little experimenting with the various styles to doing this --
 and not just for bean:message arguments.  It would be interesting to see
 if we can define a bean:setProperty property="xxx" value="yyy"/ tag that
 sets the corresponding property on the tag instance we are nested
 in.  This would solve the nested arguments case.  Taking an argX (or
 maybe "args"?) as above would also be useful in the particular case of
 bean:message.
 
 There is some complexity here with how tag instance recycling works, but
 it may actually be feasible to have a nested setter that works generally.

There has been an interesting thread on taglibs-dev on the topic 
of 'tag pipelining'.

I've included below the last proposal I made on that topic.
A key aspect of that proposal is that a "datasource" tag
directly sets an attribute of a "datasink" tag to improve performance
by avoiding "double buffering".

If you're interested in the full story, I'd suggest you check the archives
of taglibs-dev.

Would be great to have the struts community involved 
on these discussions.

Thanks,

-- Pierre

 Original Message 
Subject: Re: Amended tag pipelining proposal (was Re: PROPOSAL: tag pipelining)
Date: Fri, 02 Mar 2001 05:44:44 -0800
From: Pierre Delisle [EMAIL PROTECTED]
Reply-To: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
References: 0ea801c0a23f$a354fff0$[EMAIL PROTECTED]


Following my last email and your amended proposal, here is
(yet :-)) another proposal. We're getting there :-)

-- Pierre

-
The 'pipe' model is a way by which attributes in a 'consumer/datasink tag'
can be set implicitely via nested tags that are 'producer/datasource' tags.

The set of rules/guidelines would be as follows:

-
DataSink Tag (aka Data Counsumer Tag)

To take advantage of the 'pipe model' (i.e. allowing attributes
values to be set from nested tags), a "consumer/datasink" tag should
design these 'pipe' attributes in the following way:

- The type of that attribute should be 'Object'

   e.g. public void setFoo(Object object)

The tag should clearly document which data types it supports for
those attributes (e.g. String, InputSteam, Reader, etc...).
And with the current restrictions in the spec (which will hopefully
we lifted in 1.2 final), these attributes would be set directly
within the tag in the following way:

 x:mytag foo="%=  %" /

It should also be clear that the value specified for these attributes
is the 'real' data; not the name that refers to something that
can go out and fetch the data. Nested tags that comply with the
pipe model are to be used for that specific purpose.

To clearly identify a tag as a consumer-tag in the pipe model,
it must implement interface PipeTag.

 interface PipeSinkTag {   // or PipeConsumerTag?
 public void setPipeData(Object object) throws JspException;
 }

Method setPipeData is used to cover the case where 
a single attribute in the consumer tag can be set via nested tags. 
This attribute can be set via a pipe implicitely, without 
specifiying any attribute name.

For example:

x:mytag
  http:request url="..."/
/x:mytag

where the value of the default attribute in mytag would be set 
via the pipe setup by the http tag.

The setPipeData() method should simply make a call to setFoo(object), assuming
'foo' is that default attribute.

If more than one attribute can be set via nested tags, then 
setPipeData could be used for the attribute that's identified
as the 'default' one, or simply disallowed (i.e. pipe attribute names
would have to be stated explicetely in the producer tag).

Here is an example of a non 'default' attributes being set via nested
tags using the pipe model:

   xsl:apply
 jdbc:...  pipeProperty="xml"/ 
 io:resource name="/xsl/employees.xsl" pipeAttribute="xsl"/ 
   /xsl:apply

-
DataSource Tag (aka Data Producer Tag)

Ideally, any tag that 'produces' data (i.e. is a source of data)
should play by the rules of the pipe model, allowing tag users 
to easily reuse the data produced by these tags within any 
'consumer/datasink' tag.

To be a DataSource tag in the pipe model, a tag must abide by the
following rules:

- must support attribute 'pipeAttribute'

- must setup the 'pipe' whenever the data source object is ready
  for consumption
 
  This is done  by calling the following static method on the
  'Pipe' class:

public static boolean setPipe(Object dataSource, 
  String pipeAttribute) 

  where 'dataSource' is the dataSource object that will be consumed
  by the tag on the other side of the pipe

  where 'pipeAttribute' is the consumer tag attribute to which this 
  dataSource should be applied (can be null is no pipeAttribute attribute was 
  specified in the tag; in which case the 'default' attribute will be used in
the 
  consumer tag).

  If this method returns true, this means that the tag is engaged
  in a pipe with a 

BeanMessage Tag proposal

2001-03-16 Thread Johan Compagner

Hi,

When setting the args (arg0,arg1,arg2,arg3,arg4)
you must do this:
bean:message key="foo.foo.foo" arg0="foo1" arg1="foo2"/

But i think it is very rare that you know exactly at design time of the jsp
what value there must be. Because if you do then why not set it directly in
the message it self?

So it is almost any time a runtime expression.
But then i must do things like this:

bean:define id="argstring1" value="totalautotheft"/
bean:define id="argstring2" value="autotheft"/
bean:define id="insurance" name="carinsurance" scope="session"
type="nl.topicus.thema.DynamicForm"/
bean:message key="prompt.advise.wacasco" arg0="%=
insurance.getProperty(argstring1).toString() %" arg1="%=
insurance.getProperty(argstring2).toString() %"/


I must define
bean:define id="argstring1" value="totalautotheft"/
because i can't do this:
bean:message arg0="%= insurance.getProperty("totalautotheft").toString()
%"

I find this a bug of the Tomcat parser if you ask me. Because if he sees
that it is a reqexpr (%=)
then it should first find the % before looking at the closing "!!

Because if these problems i wanted to find a solution
Why is is not possible that i get the Object[] from a name/property???
Then the BeanTag is also not limmited to only 5 args

My example for the above one:

app:message key="prompt.advise.wacasco" (arg)name="insurance"
(arg)property="wacascoObjects"/

and the insurance.getWacascoObjects() does return the Object[] for that
string:
object[0] = insurance.getProperty("totalautotheft");
object[1] = insurance.getProperty("autotheft");
return object;

Johan Compagner














Re: BeanMessage Tag proposal

2001-03-16 Thread Michael Westbay

Compagner-san wrote:

 When setting the args (arg0,arg1,arg2,arg3,arg4)
 you must do this:
 bean:message key="foo.foo.foo" arg0="foo1" arg1="foo2"/

 [...snip...]

 bean:message key="prompt.advise.wacasco" arg0="%=
 insurance.getProperty(argstring1).toString() %" arg1="%=
 insurance.getProperty(argstring2).toString() %"/
 
 
 I must define
   bean:define id="argstring1" value="totalautotheft"/
 because i can't do this:
   bean:message arg0="%= insurance.getProperty("totalautotheft").toString()
 %"

This is exactly the problem that Pellow-san addressed with his sub-tag extentions in 
his message dated Wed, 14 Mar 2001 11:40:40 +1100, titled "Re: BaseFieldTag."

Yes, you will need to create your own BaseAttributeTags, but this is a very powerful 
method to do exactly what you want to do.

Take the above example.  It can be rewritten:

  bean:message key="prompt.advise.wacasco"
bean:arg index="0"bean:write name="insurance"
  property="totalautotheft"//bean:arg
bean:arg index="1"bean:write name="insurance"
  property="whatever"//bean:arg
  /bean:message

The bean tag will have to implement an interface that sets arg(s), the work will have 
to be moved from doBeginTag to doEndTag, and a ArgTag will have to be created in the 
light of Pellow-san's Name tag.  The changes necessary are all pretty simple.  I'm now 
working on creating all of my custom tags in that fassion.

Note:  The bean tag does not currently work like this.  This would be a way to extend 
it to cater to your needs.  We're all developers on the -dev list, right?

Hope this helps.

--
Michael Westbay
Work: Beacon-IT http://www.beacon-it.co.jp/
Home:   http://www.seaple.icc.ne.jp/~westbay
Commentary: http://www.japanesebaseball.com/