Re: Mapped properties with JSTL

2004-10-20 Thread Kris Schneider
The JSTL EL doesn't support the notion of a mapped property because the
JavaBeans Spec. doesn't support it. If your form class exposes a simple
property of type Map, then that's another story. You can use JSTL to read and
write map entries just fine.

You'll have to use JSP 2.0 before you can get close to being able to arbitrarily
invoke methods. This is done by creating EL functions. JSTL 1.1 comes with a
set of functions in addition to its taglibs.

Quoting Asleson, Ryan [EMAIL PROTECTED]:

 
 Hello,
 
 I have the following JSTL code fragment that is failing:
 
 
 c:if test=${empty form.mappedProperty[13]}
 c:set target=${form} property=mappedProperty[13] value=newValue/
 /c:if
 
 
 The form object has a method called getMappedProperty that takes a String
 as the key and returns the appropriate value.  There is also a
 setMappedProperty method that takes two Strings as parameters, the key and
 new value, and sets the value.
 
 This code is failing to compile -- at least, if fails on the c:if line.  I'm
 trying to get this to work the way the Struts tags do, where any values that
 appear in parentheses are assumed to be parameters to the underlying bean
 property method.
 
 How can I modify the above code so it does as I desire?  I figure it has to
 be close.  
 
 
 Thank you!!!

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



Re: c:import problem

2004-10-20 Thread Kris Schneider
Christian,

Not sure if you're still wrestling with this, but I just wanted to post to say
that I've been meaning to slap a little test app together as a sanity check and
I'll post back when I get the chance to code  run it...

Quoting Christian Taylor [EMAIL PROTECTED]:

 Hi,
 
 I'm new to this list, but far from a newbie when it comes to servlets, 
 JSP, JSTL and Tomcat. I've spent hours trying to debug this problem, 
 searched the net and mailing lists and haven't been able to find a 
 solution. Here is my situation:
 
 My application has many pages that use c:import to include a common 
 header. The header takes a title parameter. I've seen other people 
 doing this in the archives of this list. My code looks like this:
 
 c:import url=/include/header.jsp
   c:param name=title value=Title of the page/
 /c:import
 
 header.jsp uses the title for the title tag as well as to display to 
 the user at the top of the page.
 
 These pages can be accessed in two different ways:
 
 1) By a normal user of the application through a web browser
 2) From a servlet that uses RequestDispatchers to capture some pages
to save as files that can be viewed offline.
 
 The problem I'm having is with #2. The title parameter does NOT get 
 passed to header.jsp, and neither do request-scoped variables.
 
 My offline servlet creates request and response wrappers to pass to 
 the RequestDispatcher's include() method. The wrapped request overrides 
 the relevent parameter methods (getParameter(), getParameterMap(), 
 etc.) and provides setter methods so I can pass parameters to the pages 
 to be captured. It also defines a request-scoped variable called 
 _OfflineBackup which the pages can use to detect how they are being 
 accessed (some paths, etc. need to be different if the page is to work 
 offline).
 
 My response wrapper is a typical override getOutputStream() and 
 getWriter() to capture the output type of thing.
 
 I've looked through the Tomcat and taglibs-standard sources and can't 
 find anything that would help. The code for the c:import tag appears 
 to build a query string from the c:param tags and pass it as part of 
 the URL to the RequestDispatcher it creates, but Tomcat's 
 ApplicationDispatcher implementation doesn't seem to do anything with 
 it, from what I can see in the source (but I'm not a Tomcat developer 
 and am not that familiar with the source). The parameters in the wrapped 
 request can be accessed from header.jsp, but not the actual parameters 
 passed to header.jsp using c:param.
 
 This all leads me to my real question... why does my 'title' parameter 
 work fine when I simply view the pages normally in a browser, but not 
 when I use a RequestDispatcher and my wrapped request/response? The 
 problem appears to be that Tomcat doesn't look at the parameters in the 
 path when getRequestDispatcher(path) is called, which makes me wonder 
 why the c:param tag ever works at all (but as I said, I'm not a Tomcat 
 developer and have limited knowledge of the source so I could be wrong 
 here, this is just what I've found from digging through the sources). My 
 wrappers seem to be working fine, and the import works properly when 
 viewing the page in a browser.
 
 I hope I explained everything well enough and I apologize for this being 
 a bit long. I'm using Tomcat 5.0.28 and taglibs-standard 1.1.1. This is 
 a servlet 2.4/jsp 2.0 application. Thanks in advance to anyone who might 
 be able to help me here!
 
 Christian

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



Re: long sql string data displayed incorrectly from sql

2004-10-20 Thread Kris Schneider
Which means your data is being returned as a byte[] and you'll need to do some
post-processing to turn that into a string. Which version of JSTL are you
using? Lots of ways you could do that, of course. One would be to create a
simple helper bean (untested):

package com.dotech;

import java.io.Serializable;

public class BytesAsStringBean implements Serializable {

private String charsetName;
private String s;

// set this before using setBytes if you want a non-default charset
private String setCharsetName(String charsetName) {
this.charsetName = charsetName;
}

pulic void setBytes(byte[] bytes) {
this.s = ((this.charsetName == null) ? new String(bytes) : new
String(bytes, this.charsetName);
}

// could also override hashCode and equals

public void toString() {
return this.s;
}
}

Then use it in a JSP (untested):

jsp:useBean id=bytesAsString class=com.dotech.BytesAsStringBean/
c:set target=${bytesAsString} property=bytes value=${row.commentBody}/
c:out value=${bytesAsString}/

Quoting helmutburri [EMAIL PROTECTED]:

 Hi I have a mysql database that I is storing the data correctly however 
 if that data is of type blob or text or mediumblob or any other large 
 string object and I try to display that long string I get something 
 like this:  [EMAIL PROTECTED] or this [EMAIL PROTECTED] back on the c:out
 
 this is the code I am using?
 
   sql:query var=commentQuery
  SELECT * FROM soapBoxComments WHERE weblogID = 'c:out 
 value=${param.id}/'
  /sql:query
 
  c:forEach items=${commentQuery.rows} var=row
  br /c:out value=${row.commentUserName} /
  br /c:out value=${row.commentUserEmail} /
  br /c:out value=${row.commentBody} /
  div class=boxFooter bgLimeGreen uppercase white 
 alignRightnbsp;/div
  /c:forEach
 
 Now the c:out value=${row.commentBody} / is the data type blob.
 
 Any suggestions. All other data-types are fine.
 
 Kurt

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



Re: How to avoid the line breaks when a tag file used within javascript?

2004-10-20 Thread Kris Schneider
Rick,

Are you still pursuing this? If so, I use the following comment hack:

%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %%--
--%%@ attribute name=items required=true
type=java.util.Collection%%--
--%...

I've also seen this in use:

%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core;
%%@ attribute name=items required=true type=java.util.Collection
%...

Quoting Rick Reumann [EMAIL PROTECTED]:

 I created a simple forEach type of delimeter tag that works well for me 
 (code at end). The problem, though, is I need to use this tag within a 
 javascript method to produce a string that'll be used in a dhtml popup. 
 The problem is that, even if I make this tag file all on one line, I 
 still end up with at least one line break- that when used within the 
 javascript causes problems.
 
 For example I need to call something like..
 
 onmouseover=return doSomethingWithString('tags:MyTag .../');
 
 Is there a way to avoid the line breaks that mess up the above 
 javascript? or I guess another option is to return a String from a 
 function vs using this as a tag file? (I've looked briefly at the 
 function stuff Kris, but I'm short on time on this app and the Tag file 
 was easier to start with).
 
 As a side note if you see a better way to write this tag file I'll take 
 any suggestions (sorry the if part is hard to read but I needed no extra 
 spaces in the html output):
 
 DelimItems
 --
 %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %
 %@ attribute name=items required=true type=java.util.Collection%
 %@ attribute name=preDelim %
 %@ attribute name=postDelim %
 %@ attribute name=property required=true %
 %@ attribute name=includeFirst type=java.lang.Boolean%
 %@ attribute name=includeLast type=java.lang.Boolean%
 c:if test='${preDelim == null  postDelim == null}'
  c:set var='postDelim' value=', '/
 /c:if
 c:forEach items='${items}' var='item' varStatus='status'
  c:if test='${preDelim != null  ( includeFirst || !status.first 
 )}'${preDelim}/c:if${item[property]}c:if test='${postDelim != null 
  ( includeLast || !status.last )}'${postDelim}/c:if
 /c:forEach
 
 
 If you don't provide a pre or postDelim, it just uses comma separated 
 output, which is what I most commonly need.
 
 -- 
 Rick

-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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



Re: How to avoid the line breaks when a tag file used within javascript?

2004-10-20 Thread Rick Reumann
Kris Schneider wrote the following on 10/20/2004 3:51 PM:
Are you still pursuing this? If so, I use the following comment hack:
%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %%--
--%%@ attribute name=items required=true
type=java.util.Collection%%--
--%...
I've also seen this in use:
%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core;
%%@ attribute name=items required=true type=java.util.Collection
%...
Thanks, yes still looking:( The problem is I'm still left with just one 
closing break at the end. I had previously tried converting the whole 
tag file to one line and still I'll get one break when it's evaluated in 
the JSP. Very frustrating. The only other hack I can think of is when 
I'm iterating over my loop in my tag file I can keep prepending a c:set 
   var to make my String and I could then use that in the JSP. Seems 
like a lot overhead though. Be nice if there was a way to do c:set 
var=foo value=tags:MyTag ...// Then I could just use ${foo} 
within the javascript.


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


Re: How to avoid the line breaks when a tag file used within javascript?

2004-10-20 Thread David Schwartz
You may be able to work around it via javascript?
Try outputting the value to a hidden text field than displaying the value
property. This will not cause a javascript error  elliminates line breaks.


Quoting Rick Reumann [EMAIL PROTECTED]:

 Kris Schneider wrote the following on 10/20/2004 3:51 PM:

  Are you still pursuing this? If so, I use the following comment hack:
 
  %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %%--
  --%%@ attribute name=items required=true
  type=java.util.Collection%%--
  --%...
 
  I've also seen this in use:
 
  %@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core;
  %%@ attribute name=items required=true type=java.util.Collection
  %...
 

 Thanks, yes still looking:( The problem is I'm still left with just one
 closing break at the end. I had previously tried converting the whole
 tag file to one line and still I'll get one break when it's evaluated in
 the JSP. Very frustrating. The only other hack I can think of is when
 I'm iterating over my loop in my tag file I can keep prepending a c:set
 var to make my String and I could then use that in the JSP. Seems
 like a lot overhead though. Be nice if there was a way to do c:set
 var=foo value=tags:MyTag ...// Then I could just use ${foo}
 within the javascript.



 --
 Rick

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




David Schwartz

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



Re: How to avoid the line breaks when a tag file used within javascript?

2004-10-20 Thread Hassan Schroeder
Rick Reumann wrote:
Thanks, yes still looking:( The problem is I'm still left with just one 
closing break at the end. I had previously tried converting the whole 
tag file to one line and still I'll get one break when it's evaluated in 
the JSP. 
Sorry, I don't recall the start of this thread, but when I want to
eliminate white space from the output of a taglib I use the string
taglib -- str:trim !-- whatever -- /str:trim
Might be worth a look :-)
--
Hassan Schroeder - [EMAIL PROTECTED]
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com
  dream.  code.

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


Re: How to avoid the line breaks when a tag file used within javascript?

2004-10-20 Thread Kris Schneider
You're sure there's not a newline at the very end of your tag file?
Rick Reumann wrote:
Kris Schneider wrote the following on 10/20/2004 3:51 PM:
Are you still pursuing this? If so, I use the following comment hack:
%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core; %%--
--%%@ attribute name=items required=true
type=java.util.Collection%%--
--%...
I've also seen this in use:
%@ taglib prefix=c uri=http://java.sun.com/jsp/jstl/core;
%%@ attribute name=items required=true type=java.util.Collection
%...
Thanks, yes still looking:( The problem is I'm still left with just one 
closing break at the end. I had previously tried converting the whole 
tag file to one line and still I'll get one break when it's evaluated in 
the JSP. Very frustrating. The only other hack I can think of is when 
I'm iterating over my loop in my tag file I can keep prepending a c:set 
   var to make my String and I could then use that in the JSP. Seems 
like a lot overhead though. Be nice if there was a way to do c:set 
var=foo value=tags:MyTag ...// Then I could just use ${foo} 
within the javascript.
--
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

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