Skip to comments.
Vanity: Any Java Pros Out There? Particularly Struts?
Posted on 09/07/2004 10:14:33 AM PDT by Conservomax
Quick question - Any easy way to convert a string used by a bean:write tag into lowercase format?
TOPICS: Miscellaneous; Your Opinion/Questions
KEYWORDS: help; java; struts
Navigation: use the links below to view more comments.
first 1-20, 21-23 next last
Thanks.
To: Conservomax
2
posted on
09/07/2004 10:15:08 AM PDT
by
isthisnickcool
(Only dummies play poker with George W. Bush.)
To: Conservomax
myString.toLowerCase();
doesn't work?
3
posted on
09/07/2004 10:22:00 AM PDT
by
Physicist
To: Physicist
One would think that would work... .toLowerCase and .toUpperCase are pretty standard, no?
4
posted on
09/07/2004 10:24:21 AM PDT
by
Chad Fairbanks
(McBride fell 12 stories, hitting the pavement like a Hefty bag filled with vegetable soup.)
To: Chad Fairbanks
Part of the java.lang class. Having trouble with it?
5
posted on
09/07/2004 10:26:21 AM PDT
by
Physicist
To: Physicist
Nope, not having any trouble with it - I rarely use Java anymore... ;)
6
posted on
09/07/2004 10:27:52 AM PDT
by
Chad Fairbanks
(McBride fell 12 stories, hitting the pavement like a Hefty bag filled with vegetable soup.)
To: Conservomax
If all else fails, step through the string subtracting 32 from its ascii value. "A" in ascii is 97, 'a' is 65. There are easier ways.
7
posted on
09/07/2004 10:30:50 AM PDT
by
jwpjr
To: Chad Fairbanks
One would think that would work... .toLowerCase and .toUpperCase are pretty standard, no?The problem with that is that the tag libs use the bean standard which means that it only recognizes methods that begin with "get", so for that to work, it would have to be getLowerCase or getUpperCase.
Depending on what type of bean you are using...if it is one that you control, you can add an additional method that outputs the data in lowercase and/or create your own toString method for that bean or you can use the format attribute in the bean tag. http://struts.apache.org/userGuide/struts-bean.html#write I haven't done that, so can't tell you more.
The other option is to overwrite the bean tag to give it another attribute lowercase="true" or something like that. We've had to do that a couple of time to fix bugs that we've found.
8
posted on
09/07/2004 10:32:55 AM PDT
by
LakerCJL
To: Conservomax
Send Cyrano a freepmail. He's Java certified.
9
posted on
09/07/2004 10:33:29 AM PDT
by
Terriergal
(""Woe to you...Blind guides, who strain out a gnat and swallow a camel!"Matthew 23:23a,24)
To: Conservomax; Chad Fairbanks
See #8 below (sorry Chad, hit reply on wrong message)
10
posted on
09/07/2004 10:34:42 AM PDT
by
LakerCJL
To: LakerCJL
I don't have much experience with the Java Beans... unless you count my out-of-control coffee habit...
11
posted on
09/07/2004 10:36:30 AM PDT
by
Chad Fairbanks
(McBride fell 12 stories, hitting the pavement like a Hefty bag filled with vegetable soup.)
To: Conservomax
Not with the write tag. Why don't you add an accessor to the bean that returns the string in lower case? Something like this:
String getSomeString(){
return this.someString;
}
String getLowerSomeString(){
return this.someString.toLowerCase();
}
Then refer to the lowerSomeString property in your JSP.
bean:write name="someform" property="lowerSomeString"/
To: Conservomax
My recommendation would be to do the transformation in the appropriate Action class, and set the lower case value, as a request parameter, then reference this in the JSP. Keep your JSPs as simple as possible, and make the Action class (or preferably a helper class that the Action class delegates to) do the work.
13
posted on
09/07/2004 10:46:00 AM PDT
by
dfwgator
(It's sad that the news media treats Michael Jackson better than our military.)
To: Conservomax
How are you deciding if the bean property should be printed in lowercase? You might be entagling some business logic into your presentation layer.
If you know this should always be lower case, you might want to put that into your setter method.
I just looked it up and there's a
regexp tag library that you might be able to use, doing a s/[A-Z]/[a-z]/g but that sounds pretty expensive to do.
Can the "format" attribute help you out here? Although it looks like it only works for dates and numbers.
14
posted on
09/07/2004 10:47:02 AM PDT
by
lelio
To: lelio
Essentially what I am doing is taking a value from a JDBC connection and placing it onto the Presentation layer as a parameter value in a link.
The problem is that the data comes into the bean:write tag as a capped word and the page on teh other end can only accept stuff in lowercase.
Here's the kicker: I have no access to teh other page.
These are two GM sites being handled by 2 different companies.
The only way this will work is if I send the value as lowercase.
15
posted on
09/07/2004 10:59:49 AM PDT
by
Conservomax
(There are no solutions, only trade-offs.)
To: jwpjr
Wow...it's been too long since I've done any programming.
I thought it was the other way around with the higher ascii values representing lower case and vice versa.
16
posted on
09/07/2004 11:18:20 AM PDT
by
capt. norm
(Rap is to music what the Etch-A-Sketch is to art.)
To: capt. norm
Just checked using immediate mode in VB.NET and lowercase "a" is ascii decimal 97 uppercase "A" is decimal 65.
Add 32 to get lowercase.
17
posted on
09/07/2004 11:22:11 AM PDT
by
capt. norm
(Rap is to music what the Etch-A-Sketch is to art.)
To: Conservomax
18
posted on
09/07/2004 12:01:59 PM PDT
by
lelio
To: capt. norm
Me too, so I looked it up. Twice! Here's the url to the ascii table. Goodness knows I could have misread it! Check it out. asciitable.com
19
posted on
09/07/2004 12:37:36 PM PDT
by
jwpjr
To: jwpjr
I think you may have seen it incorrectly. The line for "A" begins with the decimal value (65), hex (41) oct 101 and the character "A" and the line continues with dec 97 etc. for lowercase "a".
I think what may be confusing is each entry starts with the decimal value and ends with the character.
20
posted on
09/07/2004 12:43:59 PM PDT
by
capt. norm
(Rap is to music what the Etch-A-Sketch is to art.)
Navigation: use the links below to view more comments.
first 1-20, 21-23 next last
Disclaimer:
Opinions posted on Free Republic are those of the individual
posters and do not necessarily represent the opinion of Free Republic or its
management. All materials posted herein are protected by copyright law and the
exemption for fair use of copyrighted works.
FreeRepublic.com is powered by software copyright 2000-2008 John Robinson