RE: Nested logic:iterate tags

2001-06-06 Thread Amos Shapira

Hi,

I just had bad experience with ServletExec 3.0E and nested
iterate tags.  When I changed the inner iterate tag back to
scriptlets things startted working again (the code worked fine
under Tomcat 3.2.1).

Is anyone aware of problems with NewAtlanta's handling of custom
tags in general or Struts in particular?

My env:

1. Sun JDK 1.2.2_5/6
2. New Atlanta ServletExec 3.0E
3. Windows 2000 Professional or Sparc Solaris 2.6
4. Jakarta Struts and Jakarta Taglib

Thanks,

--Amos

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 06, 2001 5:59 PM
To: [EMAIL PROTECTED]
Subject: Re: Nested logic:iterate tags


Marc,
Here's a sample of nested iterate tags IterateForm.java and
TimeNavDblIter.jsp.
Thanks to Craig et al  it's a piece of cake.


john ware



/   TimeNavDblIter.jsp



!doctype html public -//w3c//dtd html 4.0 transitional//en
%@ page language=java import = com.jdware.beans.* %
%@ taglib uri=/WEB-INF/struts-bean.tld prefix=bean %
%@ taglib uri=/WEB-INF/struts-html.tld prefix=html %
%@ taglib uri=/WEB-INF/struts-logic.tld prefix=logic %
html:html


%
IterateForm instance = new IterateForm();
instance.setName( yeh baby );

 pageContext.setAttribute(instance, instance,
PageContext.PAGE_SCOPE);


%
html:form action=/time 


Name: bean:write name=instance property='%= name %' filter=true
/br/
Address  bean:write name=instance property='%= address %'
filter=true /br/
table border=1 width=100%
  trthType/ththSize/th
% int h = 0; %
logic:iterate name=instance property='%= foos[0].bars %'
id=anything
  th
bean:write name=instance property='%= foos[0].bars[ + h +
].date %' filter=true /
  /th
  % h++; %
/logic:iterate
  /tr
  tr
% int i = 0; %
  logic:iterate name=instance property=foos id=anything
  tr
td
  bean:write name=instance property='%= foos[ + i + ].type
%' filter=true /
/td
td
  bean:write name=instance property='%= foos[ + i + ].size
%' filter=true /
/td

  % int j = 0; %
  logic:iterate name=instance property='%= foos[ + i + ].bars
%'  id=anything
td
  html:text name=instance property='%= foos[ + i + ].bars[ +
j + ].hours %' filter=true /
/td
% j++; %
  /logic:iterate
  /tr
% i++; %
/logic:iterate

  /table
   html:submit/
/html:form
/html:html

//  end
TimeNavDblIter.jsp

// IterateForm.java

package com.jdware.beans;


import java.util.*;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import com.jdware.util.Trace;


public class IterateForm  extends ActionForm {

public String name = TestMe;
public String address = Sischo Dr;
public IterateForm(){
foos = Foo.getFoosByMagic();
}

public static class Foo implements Comparable {
public String type;
public int size;
public Foo(){
type=foo;
size=0;
bars = Bar.getBarsByMagic();
}
public Foo( String type, int size ){
bars = Bar.getBarsByMagic();
this.type = type;
this.size = size;
}
public static ArrayList getFoosByMagic(){
ArrayList rtn = new ArrayList();
rtn.add( new Foo(typeA, 42));
rtn.add( new Foo(typeF, 2));
rtn.add( new Foo(typeW, 4));
rtn.add( new Foo(typeH, 0));
rtn.add( new Foo(typeX, 77));

return rtn;
}
public String getType(){return type;}
public void setType( String type ){ this.type = type; }

public int getSize(){ return size; }
public void setSize( int size ){ this.size = size; }
public int compareTo(Object o){
return type.compareTo( ((Foo)o).type );
}
public static class Bar implements Comparable{
/**
 *
 */
public String date;
public String getDate(){ return date; }
public void setDate( String date ){ this.date = date; }
/**
 *
 */
public String activity;
public String getActivity(){ return activity; }
public void setActivity( String activity ){ this.activity =
activity; }

/**
 *
 */
public double hours;
public double getHours(){ return hours; }
public void   setHours( double hours ) { this.hours = hours; }

public Bar(){
date = 8/5/50;
activity = nonsense;
hours = 8.5;
}
public Bar( 

RE: Help me defend Struts taglibs!!!

2001-05-31 Thread Amos Shapira

As the local neighborhood taglibs pusher in my company, I came
under some scrutiny about the lack of an Else in tags and realised
the difficulty about nesting XML tags legally, just as described by
Craig in his message below.

What I pretty quickly came up with is a switch syntax:

struts:switch condition=%= expression % 
  case value=%= true %
...
  /case
  case value=%= false %
  /case
/struts:switch

It's not stright-forward if/else, but it is (IMHO):

1. Legal XML
2. Relatively clear as an if/else clause
3. Provides a solution for a more general case of switch/case

What do you think?

Cheers,

--Amos Shapira
WebCollage

-Original Message-
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 31, 2001 6:18 AM
To: '[EMAIL PROTECTED]'
Subject: RE: Help me defend Struts taglibs!!!




On Thu, 26 Apr 2001, Scott Cressler wrote:

 One thing this argument might come down to is why custom tags, especially
 for if...else stuff (which, BTW, IMHO is not handled real well by the
 struts tags...would be nicer to have more flexibility in the conditions
you
 can check and to have the ability to do else, rather than
 logic:equal.../logic:equallogic:notEqual.../logic:notEqual...but
 that's another discussion :-).  In other words, if it is so easy to just
 slap some Java in their to do some conditional stuff, why use a clumsy
tag.
 

It turns out to be surprisingly difficult to come up with syntax for an
else construct that is legal XML syntax and isn't really ugly.

There's currently work going on in the JSP Standard Tag Library effort
(JSR-052) to create tags that will eventually be known to all containters
in the same way that tags like jsp:useBean are -- which will also deal
with a lot of the performance related concerns.  It looks like there will
be reasonable ways to do switch and if-else type processing with them.

In the mean time, we can reconsider adding an else capability in Struts
1.1, if someone can come up with a good syntax.

Craig



RE: How to use the new iterate tag?

2001-05-24 Thread Amos Shapira

Hi,

Thanks a lot!  That's exactly what I wanted.

You said that it seems like an overkill to use a tag, is there
another way to access this index?

What are the chances to see this tag in the library?

Cheers,

--Amos

 -Original Message-
 From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, May 23, 2001 7:29 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: How to use the new iterate tag?
 
 
 Do you just want to display the index? If you do, I just 
 wrote a custom tag that does that. It allows me to remove one 
 of the last instances of scriptlets that I have in my jsps. 
 It's seems overkill to have a tag that just displays the 
 iterate counter but oh well. If nothing else, you can use it 
 as an example of how to access the index of the iterate tag. 

[ rest deleted ]