You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by Glenn Nielsen <gl...@voyager.apg.more.net> on 2000/12/08 22:29:49 UTC

[Fwd: Re: ]

Mike Cannon-Brookes wrote:
> 
> Am I right in thinking that this tag can only set String attributes?
> 

Yes.

> Surely this is artificially limiting the usefulness of this tag?
> 
> How about adding an optional value attribute:
> 
> <session:setattribute name="foo" value="<%= bar %>" />
> 
> This way you could set objects as well as just Strings?
> 

Yes, this is limiting.  Here is my reasoning behind the design.

I see JSP tags as something web publishers will use in web publishing
tools.  Not programmers.  You may have noticed that none of the tags
I have written allow an attribute to be set using a runtime expression
value <rtexprvalue>.  This is a design choice I made.  Allowing <rtexprvalue>
requires that the page author enter a scriptlet of java code.  This
starts taking the tag set out of the realm where it can easily be used
by web publishers using web publishing tools.

If a web author is using only jsp tag libraries, then some other tag
that generates an object should be responsible for saving it as session
information.  Or the object they need to use could be a JSP bean, where
you can specify the session scope.

Regards,

Glenn

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

RE: [Fwd: Re: ]

Posted by Mike Cannon-Brookes <mc...@internet.com>.
<snipped>

> >
> > <symphony:story sid="4" />
> >
>
> According to the JSP 1.1 spec, 5.4.7, Life-Cycle Considerations, the way
> you use the above tag, it is closed immediately, meaning its life is over,
> and a servlet container, like Orion Server, could recycle the tag
> object.
> Unless that tag had already saved the "story" data as an
> attribute in some scope,
> the "story" data has already been marked to be GC'd before you use the
> session:setattribute tag.

Agreed. I should not have just pulled out the tag. That actually stores a
"story" object in the page scope. You can specify id="foobar" to have the
object named foobar instead.

> Why not just add a "scope" attribute to your symphony:story tag,
> then the story tag itself can save the currentstory in whatever scope
> the user wants.

This does not help me do operations on the object, ie pass it to another
custom tag.

<snipped>

> >
> > Why not add the option, and let people be responsible enough to
> decide how
> > to use the tags?
> >
>
> Since you are ok with web publishers writing little scriptlets, it would
> be just as easy for them to do.
>
> <% session.setAttribute("currentstory",story); %>
>
> and completely bypass the overhead of using the session tag at all.

Because the session tag is a minor example. Assuming the session tag
performed more than one operation for a single tag, you save lines of code.
And web publishers like tags, they're more comfortable using them. (etc etc,
the normal tag arguments that don't need to be made in taglibs-dev ;)).

And I'm still in favour of _reducing_ the number of scriptlets. It's very
easy to type <%= story %> without making syntactic mistakes, your line is
much easier to get wrong (lack of ; etc).

I honestly don't see the big deal in adding this facility, it just creates
more options for developers using the tags, helps them better integrate into
_their_ style of development and _their_ project.

I'd be interested in hearing other people's (non myself, non Glenn) opinions
on this.

-mike


Re: [Fwd: Re: ]

Posted by Glenn Nielsen <gl...@voyager.apg.more.net>.
Mike Cannon-Brookes wrote:
> 
> <<snipped>>
> 
> > > Surely this is artificially limiting the usefulness of this tag?
> > >
> > > How about adding an optional value attribute:
> > >
> > > <session:setattribute name="foo" value="<%= bar %>" />
> > >
> > > This way you could set objects as well as just Strings?
> > >
> >
> > Yes, this is limiting.  Here is my reasoning behind the design.
> >
> > I see JSP tags as something web publishers will use in web publishing
> > tools.  Not programmers.  You may have noticed that none of the tags
> > I have written allow an attribute to be set using a runtime expression
> > value <rtexprvalue>.  This is a design choice I made.  Allowing
> > <rtexprvalue>
> > requires that the page author enter a scriptlet of java code.  This
> > starts taking the tag set out of the realm where it can easily be used
> > by web publishers using web publishing tools.
> 
> This seems fairly silly to me, when it's a trivial change to allow _both_
> web publishers and programmers (two fields which are rapidly converging I
> might add) to use your tags.
> 
> For instance I have a content management system which has trivial tags like
> :
> 
> <symphony:story sid="4" />
> 

According to the JSP 1.1 spec, 5.4.7, Life-Cycle Considerations, the way
you use the above tag, it is closed immediately, meaning its life is over,
and a servlet container, like Orion Server, could recycle the tag object.  
Unless that tag had already saved the "story" data as an attribute in some scope,
the "story" data has already been marked to be GC'd before you use the 
session:setattribute tag.

Why not just add a "scope" attribute to your symphony:story tag,
then the story tag itself can save the currentstory in whatever scope
the user wants.

> which reduces all complexity of finding a story EJB etc etc. I don't think
> it's too hard to teach a web developer to put that story into a session or
> request value.
> 
> <symphony:story sid="4" />
> <session:setattribute name="currentstory" value="<%= story %>" />
> 
> Any 'web publisher' can be taught to do this, it requires no more complex
> understanding of the fundamentals than your solution.
> 
> It seems to me that sometimes people in the "we should use no scriptlets in
> JSP" artificially complicate things and force others to share the same view
> ;)
> 
> Why not add the option, and let people be responsible enough to decide how
> to use the tags?
> 

Since you are ok with web publishers writing little scriptlets, it would
be just as easy for them to do.

<% session.setAttribute("currentstory",story); %>

and completely bypass the overhead of using the session tag at all.

----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

RE: [Fwd: Re: ]

Posted by Shawn Bayern <sh...@yale.edu>.
On Sat, 9 Dec 2000, Mike Cannon-Brookes wrote:

> This seems fairly silly to me, when it's a trivial change to allow _both_
> web publishers and programmers (two fields which are rapidly converging I
> might add) to use your tags.

Glenn, I agree with this too, although I might not have put it so
strongly.  Allowing rtexprvalues isn't limiting as much as suggestive of
what, in many environments, is a poor aesthetic.  But for those who don't
subscribe to the aesthetic, I don't see any reason why the same tag
shouldn't be used.  (It's not like shutting rtexprvalue off provides a
useful clue to development environments... or does it?)

Shawn


RE: [Fwd: Re: ]

Posted by Mike Cannon-Brookes <mc...@internet.com>.
<<snipped>>

> > Surely this is artificially limiting the usefulness of this tag?
> >
> > How about adding an optional value attribute:
> >
> > <session:setattribute name="foo" value="<%= bar %>" />
> >
> > This way you could set objects as well as just Strings?
> >
>
> Yes, this is limiting.  Here is my reasoning behind the design.
>
> I see JSP tags as something web publishers will use in web publishing
> tools.  Not programmers.  You may have noticed that none of the tags
> I have written allow an attribute to be set using a runtime expression
> value <rtexprvalue>.  This is a design choice I made.  Allowing
> <rtexprvalue>
> requires that the page author enter a scriptlet of java code.  This
> starts taking the tag set out of the realm where it can easily be used
> by web publishers using web publishing tools.

This seems fairly silly to me, when it's a trivial change to allow _both_
web publishers and programmers (two fields which are rapidly converging I
might add) to use your tags.

For instance I have a content management system which has trivial tags like
:

<symphony:story sid="4" />

which reduces all complexity of finding a story EJB etc etc. I don't think
it's too hard to teach a web developer to put that story into a session or
request value.

<symphony:story sid="4" />
<session:setattribute name="currentstory" value="<%= story %>" />

Any 'web publisher' can be taught to do this, it requires no more complex
understanding of the fundamentals than your solution.

It seems to me that sometimes people in the "we should use no scriptlets in
JSP" artificially complicate things and force others to share the same view
;)

Why not add the option, and let people be responsible enough to decide how
to use the tags?

-mike