Re: input tag lib - sorting option values in select tag

2002-02-15 Thread bayard

There are a couple of insertion retaining components in Commons.Util I
think Shawn.

I'd love to play with this if I can find some time. Always thetrouble.

Bay

On Fri, 15 Feb 2002, Shawn Bayern wrote:

 On Fri, 15 Feb 2002, August Gresens wrote:

  Does anyone know how the display order of the option tags generated by
  the input:select taglib is determined? The order seems to change from
  the order in which the values are entered in the hashMap parameter.

 Yeah, this is something that lots of people run into; I should have fixed
 it long ago, but I've been focused on JSTL and not on side projects like
 'Input'.

 The order is simply what (if anything) the Map itself provides.  The Input
 taglib's select tag doesn't require a HashMap; it allows any Map and
 uses the order returned by Map.keySet().iterator().  Thus, a TreeMap would
 return the options in alphabetical order, and a HashMap leads to no
 guarantee about the options' order.

 If you want to preserve the insertion order, you'd currently need to use
 or write a Map that provides this service.  I had thought that Jakarta
 Commons 'Collections' package might have provided something like this, but
 I don't see it on its web site, so I'm probably mistaken.  One way to
 easily write it would be simply to wrap two parallel List objects:

List keys = new ArrayList(), values = new ArrayList();

public void put(Object key, Object value) {
  keys.add(key);
  values.add(value);
}

public Object get(Object key) {
  return values.get(keys.indexOf(key));
}

 and so on.

 As an aside, 'input' is one of the older taglibs; it has a few ancient
 design idosyncracies.  For instance, it should ideally support syntax like

   input:select
 input:option.../input:option
 input:option.../input:option
   /input:select

 instead of the heavy dependence on Map.

 --
 Shawn Bayern
 Author, JSP Standard Tag Library  http://www.jstlbook.com
 (coming this spring from Manning Publications)


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: escaping quotes (single and double)

2002-02-15 Thread bayard

Ditto for String taglib. It has an escapeXml format that should handle
that.

On Fri, 15 Feb 2002, Aamir Saalam wrote:

 how about using the html taglib?

 for ex. html:text property=someproperty size=35 value=%= somevalue % /

 --aamir

 -Original Message-
 From: Agrawal, Anuj (Anuj)** CTR ** [mailto:[EMAIL PROTECTED]]
 Sent: Friday, February 15, 2002 1:40 PM
 To: '[EMAIL PROTECTED]'
 Subject: escaping quotes (single and double)


 My jsp page has a form with a text field (INPUT TYPE=text) which gets its
 value pre-populated with some result from a database query.

 The problem is the string coming back from the database query could contain
 single or double quotes - so the resulting form code could look go from:

 INPUT NAME=somefield VALUE=%= somevalue %

 to:

 INPUT NAME=somefield VALUE=Welcome to my DeathStar, ladies and
 gentlemen

 which of course creates a problem during display cos of the double-quotes.

 Is there an elegant way of escaping those quotes?

 Thanks.

 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]



 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: string:substring

2002-02-13 Thread bayard

Thanks for the greater depth Alberto. The substring tags 'design' comes
completely from java.lang.String.substring, so has the following two
functions:

str:substring start=1 end=150...   MUST BE 150 or more long.
str:substring start=1...  goes up until the end.

It seems to me that this is an area for improvement as you've pointed out.
My suggestion is the following improvements(?):

1) Make the end attribute not exceptionalable. In that if the string is
only 130 long, it doesn't fubar.

2) Allow negative numbers. These would be a distance from the end and not
the start.

str:substring start=-6 end=-2One two free/str:substring

would output: 'e fr'

3) Allow just an end to be specified. This would use a start of 0. So:

str:substring end=5Hello Wurld/str:substring

would output: 'Hello'.

Anyone got any big reasons why these aren't good? The first two are doable
for both string taglib and Jakarta Commons StringUtil. The third one
isn't, which is the biggest problem I have with it.

I'll look to work these in asap, and remove them if I get any major
naysayers. They'll go in in the order I described, so Alberto can get his
desired functionality quickly.

Bay

On Wed, 13 Feb 2002, Alberto Bolchini wrote:

 Hi Bay,
 sorry for being too concise.

 I would like to write:
   str:substring start=1 end=150html:write
 property=xyz/str:substring
 without knowing weather getXyz() will return at least 150 characters or
 not.

 At the moment, if the property is empty or has less than 150 characters
 I get an out of range exception. I checked out the code, and it actually
 doesn't handle a minimum between the String.length and the end value
 provided.
 I was wondering, being new to taglibs, weather it was such by design
 or not.

 Thanks
 alberto

 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: string:substring

2002-02-13 Thread bayard


This is added as well. This change involves the tld changing so that the
start attribute of a substring tag is _not_ required. Instead it defaults
to zero.

This means there is now a 'null' operation for substring of:

str:substringSome text/str:substring

which outputs the same value. As does:

str:substring end=100Some text under 100 in length/str:substring

Bay

On Wed, 13 Feb 2002 [EMAIL PROTECTED] wrote:

 3) Allow just an end to be specified. This would use a start of 0. So:

 str:substring end=5Hello Wurld/str:substring

 would output: 'Hello'.



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: use of tags within scriptlets?

2002-02-07 Thread bayard


Is it not possible to call the libraries that are underneath the taglibs?

I've not delved into other taglibs much, but the way I've been writing
mine is that the taglib is really just an adaptor that sits on top of a
generic Java library. That way, the user can call the library if need be.

Bay

On Thu, 7 Feb 2002, Shawn Bayern wrote:

 On Thu, 7 Feb 2002, Lomvardias, Christopher wrote:

  Hi,
 
  I'm just getting started working with some of the Jakarta Taglibs. One
  thing I'm interested in doing is something like this.
 
  Let's say I've run a query and returned a result and want to place the
  value of a column into local variable. This obviously bombs.
 
  How would I do this?

 Not as such.  :-)

 You have a few choices.  You can manually invoke the tag handler class and
 call its methods (doStartTag(), doEndTag(), and so on), capturing its
 output manually.  This is somewhat tedious and error prone, and I wouldn't
 recommend it.  Alternatively, you can cause the tag to expose a scripting
 variable -- that is, a variable accessible to scriptlet code.  The tag
 needs to have this feature built in, however (by convention, using the
 id attribute)  so that you can write code like this:

   custom:tag id=foo /
   %= foo %
   % methodCall(foo); %

 DBTags's sql:getColumn tag, and the standard JSTL database tags, don't
 support scripting variables; overall, scripting code (Java within JSP
 pages) is being de-emphasized.  Instead, they expose outputs as scoped
 variables that you can access with pageContext.findAttribute().  DBTags's
 sql:getColumn has a to attribute that names the scoped attribute
 exported:

   sql:getColumn colName=fname to=fname /
   %= pageContext.findAttribute(fname); %

 The JSP Standard Tag Library (JSTL) introduces the convention of using an
 attribute named 'var' to expose scoped variables, as

   c:set var=foo
  Foo!
   /c:set

   // use 'foo' here

 For more information on what replaces scripting variables and Java code
 directly in JSP pages, you might be interested in an article I've recently
 written on the subject.  You can get to it from the front page of Manning
 Publications's web site at

http://www.manning.com

 Hope that helps explain things,

 --
 Shawn Bayern
 Author, JSP Standard Tag Library (upcoming, Manning)  http://jstlbook.com


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Newlines in attributes

2002-01-29 Thread bayard


In my example for the string-taglib, I stupidly gave an example of:

 str:replace replace=\n with=br\ndb:get value=data/str:replace

without testing. Where db:get is a hypothetical tag creating data.
The example doesn't work because the \n in the tag gets turned into a
normal 'n' before it hits the Tag object.

Is there a way to solve this that I am missing?

Sending:   \\n just sends through what you'd expect, \ and n.
And sending:  #92n does just the same.


I assume that a \t and \b etc won't work either. So my current solution is
an attribute to my tag which says to treat any \n's as being real newlines
and not the characters \ and n. Seems a bit painful though. Or a new tag.

Bay


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Standard eval tag

2002-01-27 Thread bayard

This is a suggestion to the JSTL group.

Consider the following hypothetical code:

store:get jdo=person.name/

This code returns a String, but like many taglibs does not offer the 'var'
attribute for placing the result in.

I would then like to use a piece of standard code from my company library:

Language.translateToSwahili(String)

How do I put the result of the tag into the method? Without having to
create a tag for Language. My suggested solution would be a tag which
places its body into a named variable. So:

standard:eval var=namestore:get jdo=person.name//standard:eval
%
out.write(Language.translateToSwahili(context.get(name)));
%

Or some such...

Bay


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: creation of xml-file

2002-01-06 Thread bayard


Have you considered using Cocoon?

I'm not trying to sell it at all, but if you're outputting xml as a major
part of the architecture, it would seem a better choice than jsp/servlet.

If it's just a minor part, then I would probably create a generic servlet
which takes your data objects and an xml-writer.

The xml-writer would simply have a method like:

toXml(Writer, DataObject).

Then the servlet would be either called with request parameters of:

writer=com.your.writerdao.id=5758

or they would be init-params.

Very vague I know, but those would be my two immediate avenues.

Bay

On Sun, 6 Jan 2002, Achim [iso-8859-1] Weßling wrote:

 Hallo,

 I have to create a xml-file with a jsp or servlet. Where do I start best?

 Many thanks!

 
 Achim Weßling
 [EMAIL PROTECTED]


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Bay or Glen, String Replace tag broken

2001-12-07 Thread bayard

Doh :)

Looks like a good call. Thanks Ben.

Bay

On Fri, 7 Dec 2001, Neuman, Ben J. , AFIS-HQ/IRM wrote:

 Hi!
 The String tag replace is broken. It looks like you need to change the
 StringW class method:

 static public String replaceString(String text, String repl, String with,
 int n) {
 int idx = 0;
 while( (idx = text.indexOf(repl)) != -1) {
 text = text.substring(0,idx) + with +
 text.substring(idx+repl.length() );
 idx += with.length();// jump beyond replacement
 n--;
 if(n == 0) {
 break;
 }
 }
 return text;
 }

 to:

 static public String replaceString(String text, String repl, String with,
 int n) {
 int idx = 0;
 while( (idx = text.indexOf(repl, idx)) != -1) {
 text = text.substring(0,idx) + with +
 text.substring(idx+repl.length() );
 idx += with.length();// jump beyond replacement
 n--;
 if(n == 0) {
 break;
 }
 }
 return text;
 }

 If this is alleady done, please ignore. Just trying to help.
 Thanks,
 Ben


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Bay or Glen, String Replace tag broken

2001-12-07 Thread bayard



I've fixed it by copying over a previous rewrite from Jakarta Commons
where the code lives inside the util sub-project's StringUtils. Sadly that
code is still in a sandbox and I'm hesitant to make String-taglib
dependant on code that is still living in a sandbox.

[Then I'll need to find out how to go about making the taglib dependant on
 Commons]

The rewrite basically involved switching it to using a StringBuffer for
speed.

Bay

 On Fri, 7 Dec 2001, Neuman, Ben J. , AFIS-HQ/IRM wrote:

  Hi!
  The String tag replace is broken. It looks like you need to change the
  StringW class method:
 
  static public String replaceString(String text, String repl, String with,
  int n) {
  int idx = 0;
  while( (idx = text.indexOf(repl)) != -1) {
  text = text.substring(0,idx) + with +
  text.substring(idx+repl.length() );
  idx += with.length();// jump beyond replacement
  n--;
  if(n == 0) {
  break;
  }
  }
  return text;
  }
 
  to:
 
  static public String replaceString(String text, String repl, String with,
  int n) {
  int idx = 0;
  while( (idx = text.indexOf(repl, idx)) != -1) {
  text = text.substring(0,idx) + with +
  text.substring(idx+repl.length() );
  idx += with.length();// jump beyond replacement
  n--;
  if(n == 0) {
  break;
  }
  }
  return text;
  }
 
  If this is alleady done, please ignore. Just trying to help.
  Thanks,
  Ben
 
 
  --
  To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
  For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 
 


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: unable to use string taglib

2001-12-04 Thread bayard

Hi Maciej,

I just grabbed the latest nightly build and the tagclass's are appearing
again. Sorry for the delay and stupidity on my part.

I hope you find the string taglib useful,

Bay

On Fri, 30 Nov 2001, [ISO-8859-1] Maciej Ko³odziej wrote:

 Hi,

 I'm  unable  to  use  string  taglib  in my application. I use dbtags,
 struts-* taglibs and  everything's  fine,  but  not  with  string.
 I think I've set everything correctly.
 That's what I have:

 taglib
 taglib-uri/WEB-INF/string.tld/taglib-uri
 taglib-location/WEB-INF/lib/string.jar/taglib-location
 /taglib

 in web.xml

 %@ taglib uri=/WEB-INF/string.tld prefix=str %

 in my .jsp file.
 There's string.jar in WEB-INF/lib (next to all other working ones) and
 string.tld in WEB-INF (also next to others). But when I try to compile
 the .jsp I get following error:

 comments.jsp [62:30] Unable to load class null
 Errors compiling comments.

 This is where following test part of code is:

 str:delete set=dsbajdfdkdsbdkfjdsb/str:delete

 I use Forte for Java 3.0 Enterprise (Trial) and newest nighty build of
 string taglib.


 --
 Best regards,
 Maciej


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: unable to use string taglib

2001-12-01 Thread bayard

The nightly build is definitely shagged. No tagclass's.

Have to see what jumps out at me...

On Sat, 1 Dec 2001, James Strachan wrote:

 The GUMP build certainly looks fine for jakarta-taglibs as well. Maybe its
 something wierd on Glenn's nightly build

 http://jakarta.apache.org/builds/gump/latest/jakarta-taglibs.html

 James
 - Original Message -
 From: [EMAIL PROTECTED]
 To: Tag Libraries Users List [EMAIL PROTECTED]
 Sent: Saturday, December 01, 2001 12:48 AM
 Subject: Re: unable to use string taglib


 Thanks for the report Maciej,

 It's the second time someone's reported this, so although the taglib
 builds fine for me from CVS, something must be going wrong in the nightly
 build. I'll grab a nightly build and compare the files to the output of
 CVS to see if I can figure out what's wrong.

 I'll get back with you over the weekend,

 Bay


 On Fri, 30 Nov 2001, [ISO-8859-1] Maciej Ko³odziej wrote:

  Hi,
 
  Well,  I  think  I  found  main  cause  for that error. Why there are no
  tagclass  tags  in  tags  definition  in string.tld? There's no clue
  where class files for that library are.
  I'm writing about 20011128-20011130 nighty builds.
 
  --
  Best regards,
   Maciej
 
 
  --
  To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 


 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]




 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: unable to use string taglib

2001-11-30 Thread bayard

Thanks for the report Maciej,

It's the second time someone's reported this, so although the taglib
builds fine for me from CVS, something must be going wrong in the nightly
build. I'll grab a nightly build and compare the files to the output of
CVS to see if I can figure out what's wrong.

I'll get back with you over the weekend,

Bay


On Fri, 30 Nov 2001, [ISO-8859-1] Maciej Ko³odziej wrote:

 Hi,

 Well,  I  think  I  found  main  cause  for that error. Why there are no
 tagclass  tags  in  tags  definition  in string.tld? There's no clue
 where class files for that library are.
 I'm writing about 20011128-20011130 nighty builds.

 --
 Best regards,
  Maciej


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Query Caching

2001-09-28 Thread bayard


I've long been against the idea of SQL in *SP pages for anything beyond a
one person hackup. This view was coloured by the fact I've always worked
in the programming environment and not the database environment. To me a
database is merely something that persists my data.

At the same time, I believe an OO interface to be far nicer than SQL, so I
try to hide my SQL behind standard 'Store' 'Table' objects. This makes me
far more productive and my code more readable, but makes optimising the
database interaction a real pain. 

[Another thing this approach does is tend to make the Java OO layer the
data-store and not the database. While this is exactly what I want,n it's
not usually what a legacy place will want. They need the database to be
the data-storage.]

I've recently been working with database programmers a lot. They have a
data-centric, like to do SQL, form of programming and so being able to 
something like DB Tags would appeal to them. In fact I'm surprised they
didn't choose it.

Taking that view, I could almost imagine JSP's being seen as
stored-procedures and then having a library of HTML-ing methods. Similar
to ECS. In fact, that would be a very interesting design to try, and one I
would seriously consider suggesting to DB programmers. JSP, DBTags, ECS.
Just as an experiment mind you.

Anyway, I think my summary is that something like DBTags does seem a very
bad choice from an OO/MVC viewpoint. But a DB viewpoint will probably like
them, and I'm sure it makes a lot of sense to companies porting old
websites across. Plus, a lot of companies are perfectly happy to say We
will not change from an SQL database to an OO database etc. Hell, enough
are happy to say We're sticking with Oracle, which seems less sensible.

Just some thoughts..

Bay

On 28 Sep 2001, Geoff Lane wrote:

 Slightly off topic - but I've noticed A LOT of the traffic on this list
 is about the DB Tag related stuff. Am I the only one who thinks that the
 whole idea of DB tags (for anything other than a very trivial site) is
 really a Bad Idea?
 
 It just seems to me that the domain of storage and retrieval lies way
 outside the domain of display. I'm willing to hear opinions on why
 people use these - but they totally break MVC (which not everyone cares
 about I admit).