Re: Debugging struts applications with eclipse

2006-10-25 Thread Ulrich Elsner

On 10/25/06, Joe Yuen <[EMAIL PROTECTED]> wrote:


Can anyone tell me how to debug an application running under tomcat? Is there 
any special setup I have to do in eclipse?


A popular method consists of using the sysdeo  plugin for Eclipse
(http://www.sysdeo.com/eclipse/tomcatplugin). If you then declare your
Struts project as a Tomcat project and start Tomcat using the plugin,
you can debug your code normally, i.e., by setting breakpoints,
evaluating variables etc.
A tutorial using that setup can be found at
http://javaboutique.internet.com/tutorials/three/

Regards,

Ulrich

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



Re: Action called multiple times

2006-07-11 Thread Ulrich Elsner

Hi,

just to be sure: in the Action, you do a

return null;

if everything is successful?
Everything else looks ok [1] or at least shouldn't trick Struts into
rerunning the
action. You might want to set the ContentType in the response, though.

Ulrich

[1] that is, looks just like my code, which just works with no complaints.

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



Re: What JDK version are you using?

2006-01-23 Thread Ulrich Elsner
I am using a minimum of JDK 1.4 for my Struts based applications. 1.5 has
recently been approved so I am considering moving them to Tiger if I can
find a good reason to do so (i.e., not migrating just for the sake of newness).

Ulrich

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



Re: OT: Best AJAX framework

2005-11-11 Thread Ulrich Elsner
On 11/11/05, Rafael Nami <[EMAIL PROTECTED]> wrote:
> http://dojotoolkit.org/~alex/dojo/trunk/demos/widget/Fisheye.html
>
> WOW!

+1

>
> 2005/11/11, Martin Cooper <[EMAIL PROTECTED]>:
> >
> > netsql wrote:
> > > Just to be diferent, there are alternatives to Ajax:
> > >
> > http://msdn.microsoft.com/smartclient/understanding/definition/default.aspx
> >
> > Ooh! Isomorphic is not going to like that. They've had an Ajax toolkit
> > product named SmartClient for quite a few years now.
> >
> > http://www.smartclient.com/
> >
> > --
> > Martin Cooper
> >
> >
> > > .V
> > >
> > > Rafael Nami wrote:
> > >
> > >> Super, I tested ajaxtags and really liked it, but that's how I said
> > >> before -
> > >> The team arged that before using a framework, they have to understand
> > >> what
> > >> Ajax is.
> > >>
> > >>
> > >
> > >
> >
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>

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



Passing an array of fields to ActionForm

2005-11-08 Thread Ulrich Elsner
Hi,


Well, lets see:
The first step is to display  a fixed number of text  fields that the
user can set. Say I want to have several fields "from" and "to". So, I
create a bean with
public class ZuordData {
  private String to;
  private String from;
  /* Constructors, getters setters etc */
}

Then create a List of the these beans in your form:

public class FgZuordnungForm extends ActionForm {
  private List zuordAll = new ArrayList();
   /* Constructors, getters setters etc */
}

In the preparing Action you add some values
..
List zuord = ((FgZuordnungForm) form).getZuordAll();
  zuord.add(new ZuordDate("z","a");
  zuord.add(new ZuordDate("there","here");
...

Forward to a jsp to display these Values
...



From somwhere
To somewhere


  
 
 
  
  

...

This will work (if I didn't simplify my code to much) and create HTML like:




The second step is to add new fields to enter: have your Javascript
create more input-fields of  the same type, making sure that the index
is increased, Something like

..
function addEntry(myRow, row,what) {
var myCell = document.createElement('td');
 myInput = document.createElement('input');
 myInput.setAttribute('type','text');
 myInput.setAttribute('name','zuordAll['+row+'].'+ what);
myInput.setAttribute('value',"");
myCell.appendChild(myInput);
myRow.appendChild(myCell);
}
..
var myTable = document.getElementById('fgsInner');
var totalRows = myTable.rows.length;
var myRow = document.createElement('tr');
addEntry(myRow,number,i,'from' );
addEntry(myRow,totalRows-1,'to' );
table.tBodies[0].appendChild(myRow);
...

Execute this and another row of inputs will appear. But if you try to save these
values, you will get an IndexOutOfBoundsException, because you try to
add values to  zuordAll at an index that is to big. This is where the
LazyList comes into play. If you declare

private List zuordAll=ListUtils.lazyList(new ArrayList(),
 new Factory() {
public Object
create() { return new ZuordData();
}
 });

LazyList will automatically increase the size of the list as needed.

Hope that helps,

Ulrich


On 11/8/05, Agnisys <[EMAIL PROTECTED]> wrote:
>   Will it be posible for you to send some more core around the code snippets 
> you have shown in
> your email?

>
> --- Ulrich Elsner <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > I found that the easiest way to do this is to use LazyLists. (cf.
> > http://wiki.apache.org/struts/StrutsCatalogLazyList). You can then work just
> > as you
> > with fixed lists. An example:
> >
> > in my jsp I have something like ...
> >
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
> > (Note the indexed="true"). I have a javascript function that creates more
> > table rows
> > where the  stands. These rows look just like the ones created by
> > the
> > html:text tag, except that the array-index is increased, i.e.
> > ... myInput.setAttribute('name','zuordAll['+row_cnt+'].'+ 'from');
> >
> > In the corresponding form, the List is simply declared as
> > private List zuordAll=ListUtils.lazyList(new ArrayList(),
> > new Factory() {
> > public Object create() { return new ZuordData();
> > }
> > });
> > plus the normal setter and getter. (ZuordData is just a bean with properties
> > from and to).
> >
> > Thats all. You can pass in a List of size n, add a few rows using Javascript
> > and,
> > after submitting the form get out a List of size n+k.
> >
> > Rather simple once one has figured it out.
> >
> > Hope that helps,
> >
> > Ulrich
> >
> >
> >
> >
> > On 11/6/05, Agnisys <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi,
> > > In my application the user can add any number of input text fields to add
> > > properties to a form
> > > (implemented using Javascript). Is there a way to create an ActionForm
> > > that can get an array of
> > > property values from the JSP page, without knowing how many they are? How
> > > would such properties be
> > > specified in the config file?
> > > I don't see any way of getting all these properties in a JavaBean, since a
> > > bean requires that
> > &g

Re: Passing an array of fields to ActionForm

2005-11-07 Thread Ulrich Elsner
Hi,

I found that the easiest way to do this is to use LazyLists. (cf.
http://wiki.apache.org/struts/StrutsCatalogLazyList). You can then work just
as you
with fixed lists. An example:

in my jsp I have something like ...









(Note the indexed="true"). I have a javascript function that creates more
table rows
where the  stands. These rows look just like the ones created by
the
html:text tag, except that the array-index is increased, i.e.
... myInput.setAttribute('name','zuordAll['+row_cnt+'].'+ 'from');

In the corresponding form, the List is simply declared as
private List zuordAll=ListUtils.lazyList(new ArrayList(),
new Factory() {
public Object create() { return new ZuordData();
}
});
plus the normal setter and getter. (ZuordData is just a bean with properties
from and to).

Thats all. You can pass in a List of size n, add a few rows using Javascript
and,
after submitting the form get out a List of size n+k.

Rather simple once one has figured it out.

Hope that helps,

Ulrich




On 11/6/05, Agnisys <[EMAIL PROTECTED]> wrote:
>
> Hi,
> In my application the user can add any number of input text fields to add
> properties to a form
> (implemented using Javascript). Is there a way to create an ActionForm
> that can get an array of
> property values from the JSP page, without knowing how many they are? How
> would such properties be
> specified in the config file?
> I don't see any way of getting all these properties in a JavaBean, since a
> bean requires that
> the property names and number be known statically.
> I looked at the LazyActionForm but I don't think that would help in this
> situation.
>
> Thanks,
> Anupam.
>
>
>
>
>
> __
> Start your day with Yahoo! - Make it your home page!
> http://www.yahoo.com/r/hs
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: displaying JSP errors on screen

2005-08-22 Thread Ulrich Elsner
Hi,

are you using tiles as well? I experienced the same problem some time
ago, but only in tile-based .jsp, not in 'pure' jsp. I could not
pinpoint the exact time when this started since I wasn't working on
the display part at that time but one of the bigger changes I did
shortly before I noticed this was the switch from 1.1 to 1.2.4.

After some time I got used to looking in the console for problems so
eventually I just stopped looking for the reason. Sorry that I can
offer no help, but it might console   you to know
that others have the same problem.

Ulrich

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



Re: Why interface

2005-08-10 Thread Ulrich Elsner
On 8/10/05, Laurie Harper <[EMAIL PROTECTED]> wrote:
> Carl Smith wrote:
> > In Java/J2EE community, it seems that a lot of experienced developers tend 
> > to use a lot of interfaces, however, a lot of junior developers ignore 
> > using interface. I am not sure why interfaces seem to be favorite to some 
> > experienced developers. Can some one explain this?Can you give examples 
> > where an interface is preferred?
> 
> Much more importantly than 'because Java doesn't have multiple inheritance'
>   is what Dave's alluding to, that if you code to interfaces the
> implementation can be switched without impact. As a more general example,
> consider if you wrote all your code to use ArrayList and later found, after
> profiling, that you needed to switch to LinkedList for performance reasons.
>   You'd have to update all your code -- including all the clients of all
> the methods that accepted or returned an ArrayList.
> 
> Conversely, if you coded to the List interface, you would only need to
> change the implementation code. All the client code would be unaffected.
> That's Dave's point about being able to switch X for Y with minimal impact.

And to answer the original question to why experienced developers tend
to use interfaces more often than newbies: a seasoned programmer knows
that eventually their code needs to be updated, refactored or otherwise changed.
Hence in the long run, the extra effort it takes to design the
interface will pay off.
The newbie just assumes that he will get it right the first time.

Ulrich

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



Performance profiling

2005-05-26 Thread Ulrich Elsner
Hi,

a recent load test showed that my Struts-based application has
some problems achieving the desired performance. On a small
Solaris machine it starts to slow down when reaching about 
140 requests/min, while I'd like it to handle about 200. 
Using more hardware solves the problem (on a multi-processor
machine I can easily handle over 300 requests/min) but I'd like
to avoid the additional investment.

Now, my research indicates that struts itself should easily
handle that kind of load, so the culprit is probably my own
code. 

Can anybody recommend a profiler that allows me to narrow
my search for inefficient code? I have tried EJP and did get
it running, but for some reason it returns enormous amount of
data for java.*, sun.* and some apache.* classes but not for 
my own code or for struts classes.

The actual setup is struts 1.2.4 running in a tomcat 4.1. 
behind an Apache 1.3 webserver.

Regards,

Ulrich Elsner

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



Re: [OT] Document Conversion from Word to PDF, etc.

2005-04-03 Thread Ulrich Elsner
On Apr 1, 2005 6:39 PM, Dakota Jack <[EMAIL PROTECTED]> wrote:
> Anyone with document conversion (Word --> PDF, etc) Struts programs
> out there?  What is recommended?  Cocoon, ?  Thanks.

Some months ago we researched exactly this problem, so I'll summarize
our results. We wanted to transform a group of documents that are now
created (for historical reasons) as RTF to PDF. They should look more
or less the same as before. They use some special font and contain
long tables.

- We needed to do this on a Unix machine, so all Windows-only based
solutions were out (most of them are based on calling the Word
formating engine). If you work on a Windows machine, you should
definitely try that way first. Since most people view RTF with word,
you'll get the layout they are used to, integrating fonts is easy, ...

- The best general approach seemed to be Open Office. It produces a
reasonable approximation of the Word-layout, integrating fonts is
easy, it can be used via API directly from Java. Alas, for some 
idio^W reason we could not use it, so I can't tell you if there are
some snafus later in the process.

- Different approaches using FOP (i.e., RTF->XML->PDF) failed more or
less horribly. It might be possible to get this method to work, but if
you want the same layout as in Windows, be prepared to invest huge
amounts of time for each type of document.

- We finally ended up using Ted ( http://www.nllgg.nl/Ted/ ). We do
get quite good results. It took quite some work to integrate the font
and it still has some small problem printing the font in older
versions of the Acrobat Reader, but the results look good. The author
of Ted was also quite helpful.

Hope this helps,

Ulrich

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



Re: gzip compression on HTML

2005-02-23 Thread Ulrich Elsner
Hi,

the real question is whether you really need your your application to
handle compression. Compression is normally independant from the
application and should be handled on another layer.
I would delegate this task to the HTTP-Server (e.g., using mod_gzip on
apache) or, if for some reason this is not possible, at least to the
application server (see e.g.
http://www.onjava.com/pub/a/onjava/2003/11/19/filters.html ).

Regards,

Ulrich Elsner

On Tue, 22 Feb 2005 20:40:34 +0100, Mark <[EMAIL PROTECTED]> wrote:
> Hi there,
> 
> I am fairly new to Struts and was wondering how to configure a struts
> application to use gzip compression on the HTML which is served back
> to the browser? This is fairly simple to do with regular servlets, but
> I haven't been able to find any information on how to do this with a
> struts app. Any advice or pointers would be greatly appreciated.
> Thanks!
> 
> cheers,
> Mark
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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



Re: How to view the actual HTTP generated by a struts action.

2005-01-11 Thread Ulrich Elsner
Yet another tool that might be worth checking out is Fiddler 
( ttp://www.fiddlertool.com/fiddler/ ) a free tool (Windows only :-( )
that I found quite
 helpful when analyzing HTTP traffic.

Regards,

Ulrich Elsner



On Mon, 10 Jan 2005 17:47:21 -0500, Bryce Fischer
<[EMAIL PROTECTED]> wrote:
> Jim Barrows wrote:
> >>-Original Message-
> >>From: kjc [mailto:[EMAIL PROTECTED]
> >>
> >>Is there a way to log the HTTP post string that is sent by
> >>the browser when
> >>clicking on
> >>
> >>
> >
> > Why won't right click view source not work?
> 
> I think the OP meant what the HTTP Post looks like, not what the
> generated HTML looks like.
> 
> I use a feature that comes with MyEclipse (its not unique to MyEclipse,
> but its the one I'm familiar with). I think another popular one is
> ProxyWorkbench http://www.tcpiq.com/tcpIQ/ProxyWorkbench/.
> 
> Basically, they act like a proxy. Suppose your Tomcat listens on port
> 8080.  You setup your proxy to listen to another port, like say 8081. It
> redirects to port 8080. You then setup your app to post to port 8081.
> The proxy logs the conversation.
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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



Tiles and .jsp Error reporting

2004-10-21 Thread Ulrich Elsner
Hi,

I have the following problem surface recently which I _think_ is
caused by an upgrade from Struts 1.1 to 1.2.4.
If an .jsp file containing an error (not the tag  but a error like
  (note the missing closing element /> ))
is called, I get an exception (org.apache.jasper.JasperException:
/index.jsp(1,35) Unterminated <logic:redirect> tag) displayed in
the browser.
If a .jsp file with a similar error ist part of  a tiles-based page, I
only get a blank page. This makes debugging the .jsp pages rather 
tedious. I am sure that some weeks ago I would also get an error
message in the tile-based page.

I said I think the problem was caused by an upgrade to 1.2.4 since I
haven't worked on the tiles based jsp pages for some time and I might
have changed something else in between as well. But looking through my
version control I found no change that should have changed the
behaviour of Struts, Tomcat (4.1) or Jasper.

By the way, this is an interesting problem because it only occurs when
working with broken code, something one (or at least I) does not
normally test in the standard testing frameworks. One does not test
that broken code always breaks in the same way but rather just fixes
the problem.

Any ideas?

Regards,

Ulrich Elsner

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