Re: Pagination source code

2005-12-17 Thread erh
On Thu, Dec 15, 2005 at 05:54:07PM +0530, P Prabaharan wrote:
 Hello all,
 
 I am in the urgent position to implement pagination in struts. I am not in 
 the position to use custom tags.becoz already many pages were made. I need to 
 catch all the records and do pagination.If any one have code then please send 
 to me. thanks to all
 
 
 ThanksRegards
 P.Prabaharan

Assuming this is a non-html response of some kind (since pagination of
an html page doesn't make any sense), you might want to take a look at
writing a filter using the Filter interface and the filter tag in
your web.xml.  That, however, has nothing to do with the standard taglibs
so if you need help with that you should go ask on some other list.

eric

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



Re: Break a forEach loop

2005-12-15 Thread erh
On Tue, Dec 13, 2005 at 11:02:02AM +0100, Rolf Niepraschk wrote:
 can you tell me if it is possible to break a simple forEach loop
 premature. The following doesn't work:
 
 c:forEach begin=1 end=30 varStatus=status
   ${status.count}br
   c:if test=${status.count==10}
 c:set var=status.count value=31 /
   /c:if
 /c:forEach

that's because the status variable is read-only.  It has no setCount()
method.
The easiest way, if you really can't find anyway around it, which
will probably work, is just:
% break; %

but the best way is probably to re-write your loop so you don't
need to do this.

Alternately, you could write a custom tag that uses
findAncestorWithClass() to grab the LoopTagSupport object (i.e. the
c:forEach tag object) and try using introspection to set the end
property.  (or make the specific to apache taglibs and cast it to
a org.apacheForEachTag object and call setEnd() directly)

eric

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



Re: relative paths and c:import

2005-11-22 Thread erh
On Tue, Nov 22, 2005 at 06:38:34PM +0100, Martin Kindler wrote:
 Isn't there another solution? I do control both servers but forcing to use
 absolute URLs via a CMS would be a problem.
 I can imagine witing sort of a wrapper to adapt the result of c:import, but
 this must be a common problem. So I hope someone has already done the job?

You could try to write a bunch of regex's to do things like
 s/img src=.../img src=http:.../
(good luck.  let me know which insane asylum you check into.)

Depending on the structure of your site, you could also try putting the
CMS servers content in an iframe.  Of course, that completely sidesteps
the whole issue since your jsp won't actually be doing the import anymore,
so it doesn't work if you fiddling with the data in any way.

Why is using absolute URLs a problem?  It's really the _only_ way to
refer to content that's on a different server.

If you are actually processing the data from the CMS server in your jsp page
the best way to fix it would probably be to have the jsp page entirely parse 
out the imported content and regenerate it.  Of course, that's going to be
a bit more work, and you'll probably want to communicate using xml instead
of an arbitrary web page from the CMS web server.

eric

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



Re: fmt:formatDate locale

2005-11-17 Thread erh
On Wed, Nov 16, 2005 at 10:40:17AM +0200, Eugeny N Dzhurinsky wrote:
 Hello!
 I have a problem using formatDate tag, it seem to use current locale, and in
 JSP pages I see  instead of day name, for example. Is there any way to
 provide fixed locale or convert charset when printing formatted date?

Try reading this:
http://www.onjava.com/pub/a/onjava/2002/09/11/jstl2.html

eric

(btw, you might do better to ask these questions on a general jsp/servlet
mailing list, or even a tomcat list)

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



Re: passing variable to custom tag

2005-11-14 Thread erh
On Mon, Nov 14, 2005 at 10:50:44AM +0200, Eugeny N Dzhurinsky wrote:
 On Sat, Nov 12, 2005 at 01:20:14AM -0600, [EMAIL PROTECTED] wrote:
  On Fri, Nov 11, 2005 at 09:19:00PM +0200, Eugeny N Dzhurinsky wrote:
   Actually I'm using Tomcat 5.0 and JSTL 1.1 from Jakarta. The code looks 
   like
   this:
   
   c:forEach var=obj items=${collection}
   my:custom parameter=${obj.creation_date} /
   /c:forEach
   
   And the exception is JasperException, with message -348
  What?  Are you saying you're getting an exception that looks like this:
  org.apache.jasper.JasperException: -348
  ???  Is there some reason you don't want to post the actual exception text?
  Are there any nested exceptions?  (e.g. lines that start with Caused by:
  and then another exception)
 
 Here is an exception below, it is generated when I'm calling 
 RequestDistaptcher.include(page.jsp);

hmm.. not purely jsp.  Have you tried accessing the jsp page directly?
(or, perhaps just a stripped down copy of it with just the problematic lines)

 ERROR 14/48/05 10:48:07 [http-8180-Processor24] (SecureServletTemplate:268) - 
 org.apache.jasper.JasperException: -308
 org.apache.jasper.JasperException: -308

ah, oh yeah.  There's a bit of a bug in Tomcat where certain exceptions
don't get logged properly.  The text of the exception gets passed along,
but not the exception itself.  That -308 would probably make a whole lot
more sense if you knew the actual exception type.  As it is, I have no idea
what it means.
Try wrapping the contents of the jsp page in a c:catch tag, and
logging the exception yourself.  That might help point out what the
actual problem is.  

eric

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



Re: passing variable to custom tag

2005-11-11 Thread erh
On Fri, Nov 11, 2005 at 03:39:52PM +0200, Eugeny N Dzhurinsky wrote:
 Hi, I have designed custom tag, which displays date depending of difference
 beteen current date and specified date, it looks like this
 
 jd:formatDate dates=Today,Yesterday,2 days ago 
 date=${late_messages.time_end} format=dd-MM-/
 
 But I have problem passing variable from JSTL forEach tag into my tag, it does
 not passed and throws an exeption. However date attribute in tag definition
 is defined with 'rtexpval' property. Tag definistion is below:

rtexprvalue does not have any effect on EL expressions.  It controls
whether or not you can use a run-time, e.g. %= ... %, expression.

 Could somebody please suggest how should I pass variables from JSTL tags to
 custom tags libraries?

Posted a help me message without enough detailed information isn't going to
get you many answers.  For instance, posting the actual exception that you get
would be helpful.  Showing the entire forEach block wouldn't hurt.  Maybe
even the container (Tomcat?) and version, as well as what version of the
servlet spec your webapp uses (2.4? 2.3?)

eric

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



Re: passing variable to custom tag

2005-11-11 Thread erh
On Fri, Nov 11, 2005 at 09:19:00PM +0200, Eugeny N Dzhurinsky wrote:
 Actually I'm using Tomcat 5.0 and JSTL 1.1 from Jakarta. The code looks like
 this:
 
 c:forEach var=obj items=${collection}
 my:custom parameter=${obj.creation_date} /
 /c:forEach
 
 And the exception is JasperException, with message -348
What?  Are you saying you're getting an exception that looks like this:
org.apache.jasper.JasperException: -348
???  Is there some reason you don't want to post the actual exception text?
Are there any nested exceptions?  (e.g. lines that start with Caused by:
and then another exception)

 I think it's because jasper container tries to cast ${obj} as Date object
uh, no.  If there's anything going wrong with the ${obj} variable
in the code fragment you list, it might be that it doesn't have a 
creation_date property.  i.e. it's not of the type you think it is.
I've run into problems like that several times, and throwing in a
  %= out.println(foo: + obj) %
will usually point out those cases.

 (setParameter method in tag takes java.util.Date as parameter)
 
 I think i could rewrite my code in this way:
 
 c:forEach var=obj items=${collection} scope=page
 jsp:useBean id=obj class=myObject/
 my:custom parameter=%=obj.getCreation_date()% /
 /c:forEach

You tried that and it worked?!?  That doesn't make any sense to me.
If the obj variable refers to an object of the myObject class, and that
class has a getCreation_date() method, then the reflection routines used
by the EL when resolving ${obj.creation_date} should be able to find it.
The fact that the jsp:useBean tag didn't cause a class cast exception
means that my idea that the collection has objects of the wrong type is
not correct, so I don't know what's going wrong.

eric

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



Re: Trouble with xtags:add

2005-11-10 Thread erh
On Tue, Nov 08, 2005 at 04:17:29PM +0100, Rolf Niepraschk wrote:
 I need the additional tag XX at the same level as AA just after BB. All 
 my
  trials results in the last position. The small jsp program at the end of this
 email shows the problem. I have also tried the parameter after but with no
 success (the parameter isn't described in the documentation!).
 
 Many thanks in advance,

From the docs:
add 
Parses it's body (as an XML fragment) and appends the contents to the
current node. The current node must be an Element. 


 xtags:context context=${doc} select=/
 textarea readonly=true cols=75 rows=12xtags:copyOf select=* /
 /textareabr /
 
 c:set var=tmp value=/A/BB[1] /
 xtags:context context=${doc} select=${tmp}
 xtags:add after=true
 xtags:element name=XXHugo/xtags:element/xtags:add
 /xtags:context
Since the current node in this case is the BB element, it sounds to me
like this code should result in:
A
  AA/AA/
  BBXXHugo/XX/BB
CC/
/A

I can think of two ways to do what you want:
1) in the context of /A, use xtags:replace with a body that is a
xargs:forEach over /A/* that just echoes back the element.  When
you get to the element named BB, spit it out, then the additional one.
2) Split the contents of of A using three xpaths to get BB, the
stuff before it, and the stuff after it.  Then piece those together
and replace the contents of the A node.  e.g. the xpath for everything
after the BB would be something like /A/BB[1]/following-sibling::*.

eric

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



c:import doesn't work with HEAD requests

2005-10-30 Thread erh

I've been trying to figure out why occasionally my webapp gets
Premature end of file errors when trying to parse an xml configuration
file using x:parse.  I finally figured out that it's not x:parse's fault
and the eof error is correct since the data it is getting fed ends up
being empty.
This happens when a HEAD request is received, instead of a GET reqeust.
It appears that the c:import tag doesn't actually import the requested url
in that case!
I created a minimal test case, which is attached.  The output in the
log (catalina.out) shows that when a GET is performed, the testit.xml file
is correctly read, but when a HEAD is performed the Reader object has no
data.
I am using Tomcat 5.0.30 and JSTL 1.1.1.  I looked at the release notes
for 1.1.2 but none of the bug fixes seem to apply to this.
Is there a bug for this already?  Is this perhaps a Tomcat bug?

eric
%@ taglib uri=http://java.sun.com/jsp/jstl/xml; prefix=x %
%@ taglib uri=http://java.sun.com/jsp/jstl/core; prefix=c %

c:import url=/testit.xml varReader=xmlSource
%
java.io.StringReader o = 
(java.io.StringReader)pageContext.getAttribute(xmlSource);
System.out.println(o:  + o);
char[] buf = new char[1];
while (o.read(buf)  0)
{
System.out.print(buf);
}
System.out.println();
System.out.println(--);
o.reset();
%
x:parse xml=${xmlSource} var=xmldoc /
/c:import
%
System.out.println(XX parsed ok);
%

worked: ${xmldoc}
foo
data data data
/foo

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