Transform values - Type conversion

2010-02-01 Thread Diego Manilla Suárez
Hi. I have a simple problem: I need to divide by 100 user's input in 
some fields when I'm going to store values in DB and perform the 
opposite operation when loading the form again.


I thought Struts 2 type conversion was what I needed, so I created a 
simple PercentageConverter, implementing convertFromString and 
convertToString to divide by 100 and multiply by 100, respectively. The 
first operation is performed fine, the problem is that convertToString 
is never being called. I think it has to do with the fact that the 
fields are strings themselves, so Struts thinks a conversion is not needed.


What can I do to solve this problem? I'm looking for the simplest 
solution possible.


Thanks in advance.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Re: Problems with tokenSession interceptor

2009-11-30 Thread Diego Manilla Suárez
I found the problem. I was mapping the FilterDispatcher servlet for all 
dispatchers, like this:


   
   struts2
   /*
   REQUEST
   INCLUDE
   FORWARD
   ERROR
  

So the FilterDispatcher servlet was creating new ActionContexts for each 
JSP being forwarded (I'm using Tiles). I don't remember why I mapped the 
servlet to all dispatchers, but I suppose some day I'll find out the 
reason ;)





Diego Manilla Suárez escribió:
Hi. I'm trying to use the tokenSession interceptor to prevent double 
submit problems. The problem is that this line in TokenHelper.setToken 
(invoked from  tag) always return null:


ActionContext.getContext().getSession()

I'm also using the createSession interceptor, but it's still not working.

What else should I do to get this to work?

Thanks in advance





-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org









-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Problems with tokenSession interceptor

2009-11-30 Thread Diego Manilla Suárez
Hi. I'm trying to use the tokenSession interceptor to prevent double 
submit problems. The problem is that this line in TokenHelper.setToken 
(invoked from  tag) always return null:


ActionContext.getContext().getSession()

I'm also using the createSession interceptor, but it's still not working.

What else should I do to get this to work?

Thanks in advance





-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



File upload exceeds limit -> form fields lost

2009-10-16 Thread Diego Manilla Suárez
Hi. If I set struts.multipart.maxSize to, say, 2 MB, and I try to upload 
a file larger than that, I get a validation error and my form fields 
lose their value.


Is there anything I can do so the form doesn't lose all data?

Thanks in advance.
**

* ***



-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



Testing with Spring + Struts 2 + TestNG

2009-09-11 Thread Diego Manilla Suárez

Hi. I've been struggling to have tests for my Struts 2 actions working.

I'm using Struts 2 actions created by Spring, by the means of the Struts 
2 Spring plugin.


Both Struts 2 and Spring provide their own base classes to create test 
units, and since Java doesn't allow multiple inheritance, I've tried to 
extend one of the classes and trying to replicate the functionality 
provided by the other, with no luck so far, I get all kinds of obscure 
errors, especially from the Struts 2 part.


I also want to use TestNG, not JUnit.

I was wondering if there is a base class anywhere to create unit tests 
for Struts 2 actions inside Spring.


Thanks in advance.


-
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org



[S2] JSP Exception handling

2008-09-25 Thread Diego Manilla Suárez
Hi. It seems that Struts 2 is ignoring the JSP standard approach to 
exception handling.


If I write a JSP that throws an exception, the error JSP is not loaded 
even if I put a page directive with errorPage pointing to a JSP with 
isErrorPage="true". The exception is written to stdout.


What do I need to change to control this behavior? I haven't found 
anything about this.


I've also noticed that Struts 2 doesn't render the JSP's like Struts 1 
does. It seems to perform a "progressive" rendering of the page. It 
could be a Tiles thing, though, but I would also like to know where is 
that behavoir controlled.


Thanks in advance.

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



Re: [S2] Proper way to clear error messages in session scope

2008-08-13 Thread Diego Manilla Suárez
Well, I've put this line just below the tags  and 
:


<%((ActionSupport) 
ActionContext.getContext().getActionInvocation().getAction()).clearErrorsAndMessages();%>


I don't like putting Java code on JSPs and I'm sure there is a better 
way to do it, but so far it's working.


Regards,
Diego.

Diego Manilla Suárez escribió:
Hi. I have an action in session scope. The problem is that action 
errors are never cleared and thus are shown repeatedly whenever the 
user sends the form with validation errors.


At first I put a call to clearErrors() at the beginning of mi 
validate() method, but now I'm using also the validation framework, so 
if I do that, I'm clearing its validation errors too before they are 
even shown.


I think the right place to clear errors would be right after they are 
printed, but I don't see any tag to do that.


Thanks in advance.

-
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]



[S2] Proper way to clear error messages in session scope

2008-08-12 Thread Diego Manilla Suárez
Hi. I have an action in session scope. The problem is that action errors 
are never cleared and thus are shown repeatedly whenever the user sends 
the form with validation errors.


At first I put a call to clearErrors() at the beginning of mi validate() 
method, but now I'm using also the validation framework, so if I do 
that, I'm clearing its validation errors too before they are even shown.


I think the right place to clear errors would be right after they are 
printed, but I don't see any tag to do that.


Thanks in advance.

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



Re: Struts Popup window with session param

2007-10-03 Thread Diego Ezquerro
wow, i'm feeling so stupid. i realized that just in this moment.
thank you.
 
Diego Ezquerro Bailac
Asturias, Spain

- Mensaje original 
De: Dave Newton <[EMAIL PROTECTED]>
Para: Struts Users Mailing List 
Enviado: miércoles, 3 de octubre, 2007 17:09:12
Asunto: Re: Struts Popup window with session param

IIRC somebody asked why you couldn't just access the
session parameter in the action rather than sending it
as a request parameter. What was the answer to that
question?

d.

--- Diego Ezquerro <[EMAIL PROTECTED]> wrote:

> Hi to everybody.
> 
> I have a problem with a JSP page, I think this is a
> stupid question but I was hours searching the
> Internet and found nothing.
> 
> What i wanna do is to pre-process a session
> attribute and then show a popup window with the
> result.
> My code is as follows:
> 
> 
OnClick="window.open('./fillTrazability.do?param1=srd_tree',
> '', false); return false;">Set Trazability
> 
> "srd_tree" is a session attribute and this doesn't
> work.
> 
> Then i tried this:
> 
>  href="#"
>
OnClick="window.open('./fillTrazability.do?param1=<%=
> session.getAttribute("srd_tree") %>',
> '', false); return false;">Set Trazability
> 
> and the result is a Scripting elements (<%!,
>   
> Is there any way to do this using struts tags??
> All that i want is to pass that session attribute
> (it isn't a String) to fillTrazability action class.
> 
> I've tried too:
> 
> 
>  href="#"
>
OnClick="window.open('./fillTrazability.do?param1=tree',
> '', false); return false;">Set Trazability
> 
> obtaining no results.
> 
> Anyone can help me??
> 
> Thanks a lot.
> 
>  
> Diego Ezquerro Bailac
> Asturias, Spain
> 
> 
> 
> 
> 
> 
> 
> 
>   
> ¡Sé un mejor fotógrafo!
> Perfecciona tu técnica y encuentra las mejores fotos
> en:
> 
>
http://telemundo.yahoo.com/promos/mejorfotografo.html
> 
> 
> 
> 
> 
>  
>

> ¡Sé un mejor besador!
> Comparte todo lo que sabes sobre besos. 
> 
> http://telemundo.yahoo.com/promos/mejorbesador.html


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








  

¡Sé un mejor ambientalista!
Encuentra consejos para cuidar el lugar donde vivimos.   
http://telemundo.yahoo.com/promos/mejorambientalista.html

Struts Popup window with session param

2007-10-03 Thread Diego Ezquerro
Hi to everybody.

I have a problem with a JSP page, I think this is a stupid question but I was 
hours searching the Internet and found nothing.

What i wanna do is to pre-process a session attribute and then show a popup 
window with the result.
My code is as follows:

Set Trazability

"srd_tree" is a session attribute and this doesn't work.

Then i tried this:

',
'', false); return false;">Set Trazability

and the result is a Scripting elements (<%!, 
Set Trazability

obtaining no results.

Anyone can help me??

Thanks a lot.

 
Diego Ezquerro Bailac
Asturias, Spain








  
¡Sé un mejor fotógrafo!
Perfecciona tu técnica y encuentra las mejores fotos en:

http://telemundo.yahoo.com/promos/mejorfotografo.html





  

¡Sé un mejor besador!
Comparte todo lo que sabes sobre besos.  
http://telemundo.yahoo.com/promos/mejorbesador.html

Popup window with session param

2007-10-02 Thread Diego Ezquerro
Hi to everybody.

I have a problem with a JSP page, I think this is a stupid question but I was 
hours searching the Internet and found nothing.

What i wanna do is to pre-process a session attribute and then show a popup 
window with the result.
My code is as follows:

Set Trazability

"srd_tree" is a session attribute and this doesn't work.

Then i tried this:

',
'', false); return false;">Set Trazability

and the result is a Scripting elements (<%!, 
Set Trazability

obtaining no results.

Anyone can help me??

Thanks a lot.

 
Diego Ezquerro Bailac
Asturias, Spain




  

¡Sé un mejor besador!
Comparte todo lo que sabes sobre besos.  
http://telemundo.yahoo..com/promos/mejorbesador.html

Reload a page after ActionForm

2007-09-19 Thread Diego Ezquerro
Hi to everybody.

I have a JSP that has a Tree that is modified by a submit button that sends 
data to an ActionForm.
Inside this ActionForm class, the tree is modified but only if the page is 
reloaded the tree is visually modified.

How can I reload the page after de mapping.findForward sentence?

Thanks a lot.
 
Diego Ezquerro Bailac
Asturias, Spain



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Relative paths in my webapp

2007-09-17 Thread Diego Ezquerro
Hi to everyone.

I'm developing a webapp and need to store some files and use some images stored 
in my project dir but, I have a problem with the relative paths on my app.

If I write a file in using:

File f = new File(someFileName);
f.createNewFile();
FileOutputStream fos=new FileOutputStream(f);
fos.write(fileData,0,fileSize);
fos.flush();
fos.close();
 
it's stored in netbeans-5.5.1/enterprise3/apache-tomcat-5.5.17/bin instead of 
my project root directory.

And if I try to use an image with:



then the file isn't found, and I must use absolute paths in both cases.

How can i solve this??
Isn't the root directory of the project the one who contains WEB-INF and 
META-INF directories?

Thanks so much for the answers.



Diego Ezquerro Bailac
Asturias, Spain



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Losing Session attributes

2007-08-17 Thread Diego Ezquerro
Hi to everyone.

I have a problem with the session attributes in my struts app.
I have a login page that checks the username and the password and if it's all 
right, it fills the session (in the action bean) with an attributte "username" 
with the username introduced. The app redirects to another page.

When i try to obtain the username attributte in the next page, it is seted to 
null. I have searched the web and found no answer.

I hanven't invalidated the session and don't know why this is happening.

If anybody knows a possible reason, please tell me.
 
Diego Ezquerro Bailac
Asturias, Spain



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Populate jsp form from a DB

2007-07-31 Thread Diego Ezquerro
Hi to everyone.

I need to populate a dropdown list in a Jsp page taking the data from a MySQL 
database. 
Is there any other way (more elegant) to do this than writing a bean that 
stores information and then use it from the JSP page? using struts tags or 
something like this?
I have red that is a better way using custom tags than use JavaBeans within a 
JSP.

Thanks for the answers.



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Struts tags help

2007-07-30 Thread Diego Ezquerro
Hi to everybody.

I'm developing a web app using struts and wanna know if there is a way to get 
the session attributes using struts tags.
What i want to do is something like this (within a jsp page):

<%
User user = (User)session.getAttribute("user");
out.println("Welcome " + user.getUsername() + "!");
%>

Gettin' the user attribute and then have it available in the whole page.
I've tried  but it doesn't work fine.

Thanks for the answers.



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Using JAAS with Struts and MySQL

2007-07-29 Thread Diego Ezquerro
Hi to everyone.

I'm new to Struts and I'm trying to use JAAS Authentication using mysql 
database to store usernames and passwords.
I've found tutorials in google but they show how to configure JAAS with struts 
using a file to store the authentication data of the users.
The tutorial is http://www.mooreds.com/jaas.html

Does anybody know how to do this?

Thanks for the answers.

Diego Ezquerro
Asturias, Spain



__
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
Regístrate ya - http://correo.espanol.yahoo.com/ 

Re: [S2] Problem with Date pattern

2007-06-14 Thread Diego Yasuhiko Kurisaki

Yes thats right...

When i have the following signature for the setter method

setDataInicial(java.util.Date data){

}

The method is called properly and my date is setted, but it changes dd/MM
for MM/dd, so if my date is 01/12 (first of december) in my bean it turns to
12/01 (twelveth  of january).

If i change my method to

setDataInicial(String data) {}

The method is not called, that doesn't make any sense to me.

On 6/14/07, Musachy Barroso <[EMAIL PROTECTED]> wrote:


Make sure the inputName matches the name of the setter method, I assume
you
have a getAnuncio() in your action whose result has a setDataInicial()
method right?

musachy

On 6/13/07, Diego Yasuhiko Kurisaki <[EMAIL PROTECTED]> wrote:
>
> I'm using saveFormat=rfc and java.util.Date as my object
>
> My dojo is.
>
>  displayFormat="dd/MM/" saveFormat="rfc" value="">
>
> and my setter
>
> public void setDataInicial(Date dataInicial) {
> this.dataInicial = dataInicial;
> }
>
> I've tried to change my setter method to
>
> public void setDataInicial(Date dataInicial) {
> SimpleDateFormat dateFormat = new
SimpleDateFormat("dd/MM/");
> try {
> this.dataInicial = dateFormat.parse(dataInicial);
> } catch (ParseException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
>
> But then my method was not even called...
>
>
> On 6/13/07, Musachy Barroso <[EMAIL PROTECTED]> wrote:
> >
> > Try using a Date object for your field, and set saveFormat="rfc" for
the
> > widget.
> >
> > musachy
> >
> > On 6/13/07, Diego Yasuhiko Kurisaki <[EMAIL PROTECTED]> wrote:
> > >
> > > I'm manually using the DojoTookit Date Picker withe the following
> > pattern
> > >
> > > dd/MM/yyy
> > >
> > > in my action i have a setter method like this.
> > >
> > > setDate(Date date){
> > > this.date = date
> > > }
> > >
> > > But it seens that the struts 2 when sets the method changes from
> > > dd/MM/
> > > for MM/dd/ does anyone know any solution?
> > >
> > > I've tried to make a set method that receives String and then parse
> the
> > > date
> > > by myself. But the new setMethod was not called when  the form is
> > > submitted
> > > .
> > >
> > >
> > > On 6/13/07, Torsten Römer <[EMAIL PROTECTED]> wrote:
> > > >
> > > > Everytime my app starts, I see this in the log:
> > > >
> > > > 13.06.2007 23:50:27 org.apache.struts2.config.Settings getLocale
> > > > WARNUNG: Settings: Could not parse struts.locale setting,
> substituting
> > > > default VM locale
> > > >
> > > > I put
> > > >
> > > > 
> > > >
> > > > in my struts.xml, but I still get the error (and the default VM
> locale
> > > > is used, which I don't want)
> > > >
> > > > Torsten
> > > >
> > > >
> -
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> > > --
> > > []'s Diego Yasuhiko Kurisaki
> > >
> >
> >
> >
> > --
> > "Hey you! Would you help me to carry the stone?" Pink Floyd
> >
>
>
>
> --
> []'s Diego Yasuhiko Kurisaki
>



--
"Hey you! Would you help me to carry the stone?" Pink Floyd





--
[]'s Diego Yasuhiko Kurisaki


Re: [S2] Problem with Date pattern

2007-06-13 Thread Diego Yasuhiko Kurisaki

I'm using saveFormat=rfc and java.util.Date as my object

My dojo is.

">

and my setter

public void setDataInicial(Date dataInicial) {
   this.dataInicial = dataInicial;
}

I've tried to change my setter method to

public void setDataInicial(Date dataInicial) {
   SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/");
   try {
   this.dataInicial = dateFormat.parse(dataInicial);
   } catch (ParseException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
   }
}

But then my method was not even called...


On 6/13/07, Musachy Barroso <[EMAIL PROTECTED]> wrote:


Try using a Date object for your field, and set saveFormat="rfc" for the
widget.

musachy

On 6/13/07, Diego Yasuhiko Kurisaki <[EMAIL PROTECTED]> wrote:
>
> I'm manually using the DojoTookit Date Picker withe the following
pattern
>
> dd/MM/yyy
>
> in my action i have a setter method like this.
>
> setDate(Date date){
> this.date = date
> }
>
> But it seens that the struts 2 when sets the method changes from
> dd/MM/
> for MM/dd/ does anyone know any solution?
>
> I've tried to make a set method that receives String and then parse the
> date
> by myself. But the new setMethod was not called when  the form is
> submitted
> .
>
>
> On 6/13/07, Torsten Römer <[EMAIL PROTECTED]> wrote:
> >
> > Everytime my app starts, I see this in the log:
> >
> > 13.06.2007 23:50:27 org.apache.struts2.config.Settings getLocale
> > WARNUNG: Settings: Could not parse struts.locale setting, substituting
> > default VM locale
> >
> > I put
> >
> > 
> >
> > in my struts.xml, but I still get the error (and the default VM locale
> > is used, which I don't want)
> >
> > Torsten
> >
> > -----
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> []'s Diego Yasuhiko Kurisaki
>



--
"Hey you! Would you help me to carry the stone?" Pink Floyd





--
[]'s Diego Yasuhiko Kurisaki


[S2] Problem with Date pattern

2007-06-13 Thread Diego Yasuhiko Kurisaki

I'm manually using the DojoTookit Date Picker withe the following pattern

dd/MM/yyy

in my action i have a setter method like this.

setDate(Date date){
this.date = date
}

But it seens that the struts 2 when sets the method changes from dd/MM/
for MM/dd/ does anyone know any solution?

I've tried to make a set method that receives String and then parse the date
by myself. But the new setMethod was not called when  the form is submitted
.


On 6/13/07, Torsten Römer <[EMAIL PROTECTED]> wrote:


Everytime my app starts, I see this in the log:

13.06.2007 23:50:27 org.apache.struts2.config.Settings getLocale
WARNUNG: Settings: Could not parse struts.locale setting, substituting
default VM locale

I put



in my struts.xml, but I still get the error (and the default VM locale
is used, which I don't want)

Torsten

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





--
[]'s Diego Yasuhiko Kurisaki


Re: [S2] needs refresh to work properly

2007-05-07 Thread Diego Yasuhiko Kurisaki

Well i spent a hour to realize that when i used the property tag and go no
output, i was mistyping the name :/

it worked using just the name of the method that i want.



Thanks

On 5/7/07, Diego Yasuhiko Kurisaki <[EMAIL PROTECTED]> wrote:


Well, using the property tag i got no output at all.



I'll try to use the webwork stuff.

Is this really how it works?

On 5/7/07, Adam Ruggles <[EMAIL PROTECTED]> wrote:
>
> have you tried using the property tag instead?  value="ca.name" />
>
> Diego Yasuhiko Kurisaki wrote:
> > Hi i've written the following in a JSP.
> >
> > 
> > 
> >${ca.name}
> >${ca.description }
> >remove
> >edit
> > 
> > 
> >
> > I have a method in my action called getClients.
> >
> > When i first load the page, the iterator tag generates the exact
> > number of
> > rows of the list that is returned by the getClients method.
> > But the EL ${ca.name } and ${ca.description} doesn't return any value
> > until a
> > refresh.
> >
> > I've tried then putting a breakpoint inside the getName and
> > getDescription
> > methods, it seens that the methods are being called just after the
> first
> > refresh.
> >
> > Looks like i'm doing something very wrong, am i not supposed to use EL
> > inside ? What should i use then?
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
[]'s Diego Yasuhiko Kurisaki





--
[]'s Diego Yasuhiko Kurisaki


Re: [S2] needs refresh to work properly

2007-05-07 Thread Diego Yasuhiko Kurisaki

Well, using the property tag i got no output at all.



I'll try to use the webwork stuff.

Is this really how it works?

On 5/7/07, Adam Ruggles <[EMAIL PROTECTED]> wrote:


have you tried using the property tag instead? 

Diego Yasuhiko Kurisaki wrote:
> Hi i've written the following in a JSP.
>
> 
> 
>${ca.name}
>${ca.description}
>remove
>edit
> 
> 
>
> I have a method in my action called getClients.
>
> When i first load the page, the iterator tag generates the exact
> number of
> rows of the list that is returned by the getClients method.
> But the EL ${ca.name} and ${ca.description} doesn't return any value
> until a
> refresh.
>
> I've tried then putting a breakpoint inside the getName and
> getDescription
> methods, it seens that the methods are being called just after the first
> refresh.
>
> Looks like i'm doing something very wrong, am i not supposed to use EL
> inside ? What should i use then?

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





--
[]'s Diego Yasuhiko Kurisaki


[S2] needs refresh to work properly

2007-05-07 Thread Diego Yasuhiko Kurisaki

Hi i've written the following in a JSP.



   ${ca.name}
   ${ca.description}
   remove
   edit



I have a method in my action called getClients.

When i first load the page, the iterator tag generates the exact number of
rows of the list that is returned by the getClients method.
But the EL ${ca.name} and ${ca.description} doesn't return any value until a
refresh.

I've tried then putting a breakpoint inside the getName and getDescription
methods, it seens that the methods are being called just after the first
refresh.

Looks like i'm doing something very wrong, am i not supposed to use EL
inside ? What should i use then?
--
[]'s Diego Yasuhiko Kurisaki


Re: Send a 403 response

2005-05-31 Thread Diego Manilla Suárez

Diego Manilla Suárez wrote:

Hi! I need to implement some kind of security inside of an Action. 
When the user doesn't meet certain criteria, I must send him to the 
"forbidden" page. Right now I'm doing this:


if (!allowed) {
   response.sendError(HttpServletResponse.SC_FORBIDDEN);
   return null;
}

The problem is that the user is sent to the default error page of 
Tomcat, instead of the 403 page defined in web.xml. Are the lines 
above wrong?


Thanks in advance.



Ok, I found the problem: there was a filter that wasn't forwarding the 
error.


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



Send a 403 response

2005-05-31 Thread Diego Manilla Suárez
Hi! I need to implement some kind of security inside of an Action. When 
the user doesn't meet certain criteria, I must send him to the 
"forbidden" page. Right now I'm doing this:


if (!allowed) {
   response.sendError(HttpServletResponse.SC_FORBIDDEN);
   return null;
}

The problem is that the user is sent to the default error page of 
Tomcat, instead of the 403 page defined in web.xml. Are the lines above 
wrong?


Thanks in advance.


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



Re: what do you suggest me? iBatis or Hibernate

2005-03-19 Thread Diego Espada
David,

In my opinion, that's incorrect. Hibernate lets you specify composite
primary keys, foreign keys (automatic, thanks to one-to-many
relationships), indexes, unique fields and most of the features
supported by major databases. You can search by fields using HQL, an
object oriented SQL-like query language. It has nothing to do with
serialization (at least, what I take as serialization), it can store
your data in a clean, tabular oriented way.

It has even features to support legacy applications.

Hibernate does not constraint your DB schema normalization form, the
only constraint that could exist is imposed by the programmer when he
gives shape to its domain model.

Bye !!

On Fri, 18 Mar 2005 22:13:14 -0500, David Haynes
<[EMAIL PROTECTED]> wrote:
> Hibernate uses the database as a reliable data store for serialized
> objects. It does not exploit the higher level capabilities of the
> database to assist with referential integrity or the benefits of a more
> normalized form. (At least it looks that way in examining the results of
> its UML to data schema translations.)
> 
> If that is sufficient for your needs it should be OK. If you need any of
> these higher level functions or want to access the database efficiently
> through alternate means (e.g. ETL to DSS stores) this may present an issue.
> 
> -david-
> 
> Tak Yoshida wrote:
> 
> >I think,
> >
> >If you don't have to work with DBA to tune up your application's SQL
> >or
> >if you don't have to work with or share SQLs to any backend PL/SQL programmer
> >or
> >you don't know SQL very much
> >The answer could be Hibernate.
> >
> >If yes, as usual enterprise applications, iBATIS could be the answer.
> >
> >Tak
> >
> >Milson Cardona wrote in <[EMAIL PROTECTED]>
> >
> >
> >>Hi
> >>
> >>I am novice in J2EE.
> >>
> >>I have been working with JDBC (SQL statements within of business
> >>class), but now desire to work with persitence objects.
> >>
> >>I know that this are different, Hibernate is then biggest, but iBatis
> >>have a knowledge curve very short
> >>
> >>what do you suggest me?  iBatis or Hibernate.
> >>
> >>thanks
> >>
> >>-
> >>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]
> 
>

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



Re: what do you suggest me? iBatis or Hibernate

2005-03-18 Thread Diego Espada
I disagree with you in some of those points.

If you don't know SQL, don't go with Hibernate.
You'll have terrible performance problems if you do so. Hibernate has
very complete features to tweak performance and optimize queries, and
to make use of that you have to know SQL.

I don't know iBATIS, so i don't know what advantages has over
Hibernate. But i can tell you that I've used Hibernate in an
enterprise application that was running previously on a commercial
J2EE application server with CMS with 80 users constantly beating the
Database, and the performance gains where impressive.

For the other part, if you don't know SQL, I wouldn't recommend that
you use the domain model pattern... It would be too dangerous. I would
use transactions scripts with JDBC, let a DBA design the database and
that's it.

Bye !!!


On Fri, 18 Mar 2005 21:54:28 -0500, Tak Yoshida
<[EMAIL PROTECTED]> wrote:
> I think,
> 
> If you don't have to work with DBA to tune up your application's SQL
> or
> if you don't have to work with or share SQLs to any backend PL/SQL programmer
> or
> you don't know SQL very much
> The answer could be Hibernate.
> 
> If yes, as usual enterprise applications, iBATIS could be the answer.
> 
> Tak
> 
> Milson Cardona wrote in <[EMAIL PROTECTED]>
> >Hi
> >
> >I am novice in J2EE.
> >
> >I have been working with JDBC (SQL statements within of business
> >class), but now desire to work with persitence objects.
> >
> >I know that this are different, Hibernate is then biggest, but iBatis
> >have a knowledge curve very short
> >
> >what do you suggest me?  iBatis or Hibernate.
> >
> >thanks
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> 
> --
> Tak Yoshida mailto:[EMAIL PROTECTED]
> 
> -
> 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: help needed on ActionForm and ActionForward behaviour

2005-03-18 Thread Diego Espada
Did you check the scope configuration parameter ?
Bye


On Fri, 18 Mar 2005 16:21:23 +0100, Gaet <[EMAIL PROTECTED]> wrote:
> In other words, I would like to implemnt a button "Save and display next
> employee"
> 
> How to do this?
> 
> 
> - Original Message -
> From: "Gaet" <[EMAIL PROTECTED]>
> To: "Mailing List Struts" 
> Sent: Friday, March 18, 2005 10:06 AM
> Subject: help needed on ActionForm and ActionForward behaviour
> 
> Hi,
> 
> I have a DispatchAction class, that I use to handle the employee information
> Edit.
> On my jsp page, I have two button, on to validate the updates and forward
> back to the employee list => that works great.
> On the other button, I want to validate the updates and display the next
> employeeI could'nt make it work :o(
> 
> When my JSP page is refreshed after a click on this buttoon, the problem is
> that when the form displayed contains the information of the employee we
> have validatedbut the form in my action class contains the information
> of the next employeewhy this behaviour?
> 
> Many thanks for your help since I'm on this problem for 2 days now! it looks
> me crazy...
> 
> -
> 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: html: tags part2

2005-03-18 Thread Diego Espada
You could just use

 wrote:
> Scott Purcell wrote the following on 3/18/2005 1:29 PM:
> 
> > Can I create a image that is a src for a submit, or cancel, or js function?
> 
> Why not just use a regular image wrapped with an href and use javascript?
> 
> example...
> 
> 
>
> 
> 
> --
> Rick
> 
> -
> 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: Wouldn't validation be better performed by Actions rather than ActionForms?

2005-03-18 Thread Diego Espada
I do all my validations in the action, and it works great for me. I
built a layer upon the action that allows me to activate / deactivate
validation for some actions. So i turned my actions into page
controllers.

I suppose some people would argue that this "resists" the framework,
but i think that i'm so comfortable working like that !!

bye


On Sat, 19 Mar 2005 02:01:28 +, David Kennedy
<[EMAIL PROTECTED]> wrote:
> Sorry, this is going to be a fairly off-topic reaction post, but
> Lawrie's comments struck a chord with me.
> 
> Lawrie Gallardo wrote:
> > I'm relatively new to Struts and I have to say that I've found it to
> > have a realtively steep learning curve. And the only reason for this is
> > that there are so many different ways to do things and no definitive
> > best ways of achieving anything.
> 
> I totally agree. I have just transitioned to the web tier from a career
> slaving away at the back-end of large Java server systems for telecomms
> and finance. I was looking forward to using Struts quite a bit,
> suspecting, perhaps wrongly, that the nature of web tier work would mean
> a fast evolution of high-quality tools. Maybe I've been spoilt by a life
> dominated by strict (read: paranoid) coding practices, Ant and JUnit,
> but Struts is rather a confusing mess once past the initial "Oh, cool, a
> working action and page!" phase. And this is coming from someone who has
> just fled EJB land...
> 
> For example, I've got a couple of Really Common Requirements - logon and
> a side nav bar / tree view. I've been amazed that I've not found a
> simple, standard example for either of these. Instead, I've tripped over
> a wealth of little fiddly details that derailed my progress. Nothing
> like lots of soft XML config to really trip you up with details I
> find... "I've never even heard of that option, and when I tried to use
> it I wasted 5 hours not noticing a typo in one of the repeated strings!"
> 
> > I'd much rather there was a bit
> > of focus to the framework than the mass of competing options. "Make the
> > simple things simple and the hard things possible" and all that...
> 
> Totally agree. For example, I did some work with Struts Layout:Treeview
> for my nav bar prototype. I very much appreciate volunteer effort, and
> don't wish to knock anyone's efforts, but I have to say that for a
> standard solution advocated by a couple of books it's fairly poor...
> There were a couple of immediate show-stoppers with working with the
> Treeview which was very disappointing. (Turns out the license precludes
> commercial use anyway.) The point of this isn't to knock Layout (again,
> I appreciate effort and feel guilty that I don't pay back into the
> commnunity that makes me fine tools), but rather to illustrate how
> something fairly standard - a treeview nav bar with a load of
> actions/forwards - is surprisingly difficult for a beginner with the
> toolkit to knock up cleanly.
> 
> I guess some of this cognitive whiplash comes from the fact that several
> of the core components are Very Cool. The core idea of the actions is
> just Very Sensible, the basic idea of using ResourceBundle keys
> everywhere Just Works, etc. I particularly like Validator, although I
> can see, as this thread is discussing, room for disagreement about
> alternative implementations. Custom rules are very nice, and very easily
> added. I'm just troubled by the fact that most of the elements I find
> straightforward and cleanly finished are those which my boss just
> doesn't see! The basic project elements he wants in a couple of days -
> that tree view in a readable/maintainable form, a nice simple PAM login
> & timeout mechanism* - turn into real timesinks. (Actually, to be fair,
> the move from 1.0 -> 1.1 and similar shifts in several libaries also led
> to confusion when working from Googled, and often conflicting, advice.)
> 
> This is a rather rude rant I know, and I appreciate people are
> scratching their own itches, but it would be nice to seem some concerted
> effort to solve some of the FAQs cleanly, and to generate more of a core
> catalogue of Patterns for noobs like myself. (Kudos to people like Ted
> Husted who do maintain some useful resources.) In that vein, I'm very
> much looking forwards to the new Struts Cookbook that O'Reilly have just
> put out, was rather hoping to see it in the post this morning. Might
> well answer lots of questions for me.
> 
> I'm not sure I should hit 'Send' on this for fear of offending people,
> please just see this as constructive initial impression feedback. I see
> a lot of promise in the Struts toolkit, better be, sort of bet the
> project on it now!, and would love to see more consensus emerging about
> Best Practices.
> --
> David Kennedy
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---

Re: what do you suggest me? iBatis or Hibernate

2005-03-18 Thread Diego Espada
I haven't used iBatis to tell the truth, but I've used Hibernate
extensively (even in a critic project) and it is really a great
product. It has an amazing set of features and a big base of users.

The learning curve is a bit high, though. If you use Hibernate, you
should plan taking into account that.

Bye.


On Fri, 18 Mar 2005 15:38:45 -0500, Milson Cardona
<[EMAIL PROTECTED]> wrote:
> Hi
> 
> I am novice in J2EE.
> 
> I have been working with JDBC (SQL statements within of business
> class), but now desire to work with persitence objects.
> 
> I know that this are different, Hibernate is then biggest, but iBatis
> have a knowledge curve very short
> 
> what do you suggest me?  iBatis or Hibernate.
> 
> thanks
> 
> -
> 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: Is Struts All right ?

2005-03-11 Thread Diego Espada
so is not using anymore ??
THAT i didn't know !!
Thanks !!


On Fri, 11 Mar 2005 12:59:13 -0600, Joe Germuska <[EMAIL PROTECTED]> wrote:
> At 3:26 PM -0300 3/11/05, Diego Espada wrote:
> >Ok,
> >
> >the problem with this is that we cannot look for common problems in
> >the list. It doesn't allow you to search, and, for example, if you
> >click in "by subject" in the mailing list, you get this:
> 
> The problem with which?  You are searching using Eyebrowse.  I don't
> recommend using Eyebrowse.  Presumably no one has had the time or
> energy to make it work right, but why bother when GMane has such a
> nice interface?
> 
> >  > I've never caught on to Eyebrowse, although it's the list archiving
> >>  tool installed on Apache hardware.  I recommend GMane
> >>  http://news.gmane.org/gmane.comp.jakarta.struts.user
> >>
> >>  Some people like MARC:
> >>
> >>  http://marc.theaimsgroup.com/?l=struts-user
> 
> --
> Joe Germuska
> [EMAIL PROTECTED]
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction"  -The Ex
> 
> -
> 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: Is Struts All right ?

2005-03-11 Thread Diego Espada
Ok,

the problem with this is that we cannot look for common problems in
the list. It doesn't allow you to search, and, for example, if you
click in "by subject" in the mailing list, you get this:

VelocityServlet: Error processing the template

General error: Got error 127 from table handler
org.apache.velocity.exception.VelocityException: General error: Got
error 127 from table handler
at org.tigris.eyebrowse.servlets.EyebrowseServlet.handleRequest(Unknown 
Source)
at 
org.apache.velocity.servlet.VelocityServlet.doRequest(VelocityServlet.java:396)
at org.tigris.eyebrowse.servlets.EyebrowseServlet.doRequest(Unknown 
Source)
at 
org.apache.velocity.servlet.VelocityServlet.doGet(VelocityServlet.java:355)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at 
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at 
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at 
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at 
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at 
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
at 
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at 
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at 
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at 
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at 
org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
at 
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
at 
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
at 
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
at java.lang.Thread.run(Thread.java:534)



On Fri, 11 Mar 2005 12:22:06 -0600, Joe Germuska <[EMAIL PROTECTED]> wrote:
> At 3:04 PM -0300 3/11/05, Diego Espada wrote:
> >Hello ? I'm totally surprised about the current state of the Struts
> >web site...
> >
> >1) I couldn't find the address to subscribe to this list. I just made
> >it up, imagining that it would be the same as the Tomcat list.
> >2) The Mailing list archive functionality is at 20 % at best. You
> >can't search messages, browse them ordering by subject or other
> >criteria, or browse certain categories. Almost everything that you do
> >returns a stack trace.
> >
> >Is the struts web site being mantained ??
> 
> We're in the midst of a considerable reorganization of the source
> code repository, which is also where the documentation is maintained.
> It's been a while, but I believe that James is close to having us
> ready to build the docs, at which time we could refresh the public
> site.
> 
> I've never caught on to Eyebrowse, although it's the list archiving
> tool installed on Apache hardware.  I recommend GMane
> http://news.gmane.org/gmane.comp.jakarta.struts.user
> 
> Some people like MARC:
> 
> http:/

Validator with more than one module

2005-03-11 Thread Diego Espada
Hi

I'm trying to use the validator with one that more Struts module, but
I've found that if you've more than one module, only one of them load
the validation xmls correctly, the others don't.

Having this in the web.xml

/WEB-INF/struts-config-one.xml, /WEB-INF/struts-config-two.xml:

Each one loading their own validation.xml (validation-one and
validation-two), only struts-config-two loads the validator correctly.
The other validation is ignored by Struts.

If I switch the order of the files, it works the other way around.

I've seen in the Internet sort of this problem happened in previous
versions of Struts. I've tested this in 1.2.6 beta and 1.2.4 and the
problem is present.

Is there a patch or workaround for this ? 

Thanks

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



Is Struts All right ?

2005-03-11 Thread Diego Espada
Hello ? I'm totally surprised about the current state of the Struts web site...

1) I couldn't find the address to subscribe to this list. I just made
it up, imagining that it would be the same as the Tomcat list.
2) The Mailing list archive functionality is at 20 % at best. You
can't search messages, browse them ordering by subject or other
criteria, or browse certain categories. Almost everything that you do
returns a stack trace.

Is the struts web site being mantained ??
Thanks...

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



Re: Add action mappings on the fly

2005-02-22 Thread Diego Manilla Suárez
Thanks everyone for your replies. I didn't know the wildcard matching 
feature in action mappings. With this feature and map-backed ActionForms 
now I can do more or less what I wanted to do.

Regards,
Diego.
Joe Germuska wrote:
At 12:39 PM +0100 2/21/05, Diego Manilla Suárez wrote:
Hi! I'm trying to add an ActionMapping definition dinamically (using 
ModuleConfig.addActionConfig method), but I get an 
IllegalStateException (configuration is frozen). Is there a way to do 
what I want?

Well, you haven't really explained what you want! As Struts is 
implemented, no, you can't add action configs; on the other hand,  
ModuleConfig is an interface, so you could provide a different 
implementation of ModuleConfig which either didn't use freezing 
(probably a bad idea, unless you come up with an alternative way to 
deal with synchronization issues in a multi-threaded execution 
environment) or which created a new ActionConfig object as needed.  
This is essentially what Struts already does in supporting wild-card 
matched action paths.  It locates the ActionConfig whose path pattern 
matches the current request path and clones it, optionally replacing 
certain values based on the match.

Joe

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


Add action mappings on the fly

2005-02-21 Thread Diego Manilla Suárez
Hi! I'm trying to add an ActionMapping definition dinamically (using 
ModuleConfig.addActionConfig method), but I get an IllegalStateException 
(configuration is frozen). Is there a way to do what I want?

Thanks in advance.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Process tiles definition from a different module

2005-01-27 Thread Diego Manilla Suárez
Hi! I need to process a tiles definition that is located in a different 
module. I have this ActionForward declared on the module I want to invoke:


And on the main module, I have this code (in an action) to get that 
forward definition.

ActionForward forward = null;
ServletContext context = getServlet().getServletContext();
ModuleConfig config = 
ModuleUtils.getInstance().getModuleConfig("othermodule", context);
if (config != null && 
"org.apache.struts.action.ActionForward".equals(config.getActionForwardClass())) 
{
  forward = (ActionForward)config.findForwardConfig("myPage");
}
return forward;

This doesn't work because Tiles is not processing the definition 
".myTilesDefinition" (I have two separate Tiles definition 
configurations, one for each module). How can I get the definition on 
the other module processed by Tiles?

I know I can import the definitions of the second module using 
 in struts-config.xml, 
but I'm wondering if it's possible to do what I want without this 
"trick". With TilesUtilStrutsModulesImpl class I get the 
DefinitionsFactory object for the second module, but I can't get past there.

Thanks in advance.
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Problems initializing form objects

2004-12-14 Thread Diego Manilla Suárez
Hi Jeff, thanks for your answer. I was already doing that, using two 
actions (well, using two different methods of a LookupAction), one to 
initialize the list and the other to process it, but the problem arises 
when I submit the form in "page.jsp".

Jeff Beal wrote:
When I have this sort of thing, I usually put it in an "initializer" 
Action that I always link to in place of the JSP.


  
  


  


-- Jeff
Diego Manilla Suárez wrote:
Hi! I have a problem with form members initialization.
I have this form.
public class BasicContentForm extends ValidatorForm {
   protected java.util.List propertyValues;
 public BasicContentForm() {
   this.propertyValues = new java.util.ArrayList();
   }
 public void setPropertyValues( java.util.List propertyValues ) {
   this.propertyValues = propertyValues;
   }public java.util.List getPropertyValues() {
   return this.propertyValues;
   }
 public Object getPropertyValue(int index) {
   return propertyValues.get(index);
   }
 public void reset(ActionMapping mapping, HttpServletRequest 
request) {
   this.propertyValues = new java.util.ArrayList();
   }
}

And this jsp:




The problem is that the number and type of the elements of 
propertyValues list is calculated dynamically (from the database). I 
was doing that on my Action class, but I've realized that this 
doesn't work: when I submit the form, I get an Exception at 
BeanUtils.populate, because the list is not properly initialized. If 
I can't initialize it on the reset() method (I need to access the 
database), what else can I do?

Thanks in advance

-
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: Problems initializing form objects

2004-12-14 Thread Diego Manilla Suárez
Thanks a lot for your answers, Andrew. I think I can't use a LazyList. 
The problem is that I don't only need to know the size of the list 
dynamically, but also the type of its objects. All of them share a 
common interface, but their concrete class is unknown beforehand, so I 
can't make the list grow automatically.

I've been also suggested to extend RequestProcessor, overriding 
processPopulate to perform proper initialization before calling 
RequestUtils.populate(), and thus before BeanUtils.populate(). What do 
you think about this?

Andrew Hill wrote:
The problem here is the need to be able to populate the form from a 
submission. Initialising it in the action before forwarding to the 
view is okay when rendering the page to the browser, but when 
interpreting the forms submission, struts is going to instantiate the 
new actionform instance (its request scoped I presume), call its 
reset(), and then try to populate it, before any action is invoked.

The only place to initialise the size of the list so populate will 
work is in the reset() method, however its naughty to connect to the 
database (to find out the required size) from here.

My first suggestion was to use a lazy list. Thats probably the best 
way, but another simple method would be to write the size of the list 
to a hidden field in the html. Then it will be sent back in the 
submitted request. You can then check that in the reset() method using 
getParameter().
ie (at its simplest), in reset() :

int size = Integer.parseInt( request.getParameter("myListSize") );
this.propertyValues = new ArrayList(size);
Ummm. I was having another look at that wiki link I sent. Its notable 
that their example provides an indexed getter. You may also need to do 
something like that, but I dont recall the details :-(

Jeff Beal wrote:
When I have this sort of thing, I usually put it in an "initializer" 
Action that I always link to in place of the JSP.


  
  


  


-- Jeff
Diego Manilla Suárez wrote:
Hi! I have a problem with form members initialization.
I have this form.
public class BasicContentForm extends ValidatorForm {
   protected java.util.List propertyValues;
 public BasicContentForm() {
   this.propertyValues = new java.util.ArrayList();
   }
 public void setPropertyValues( java.util.List propertyValues ) {
   this.propertyValues = propertyValues;
   }public java.util.List getPropertyValues() {
   return this.propertyValues;
   }
 public Object getPropertyValue(int index) {
   return propertyValues.get(index);
   }
 public void reset(ActionMapping mapping, HttpServletRequest 
request) {
   this.propertyValues = new java.util.ArrayList();
   }
}

And this jsp:




The problem is that the number and type of the elements of 
propertyValues list is calculated dynamically (from the database). I 
was doing that on my Action class, but I've realized that this 
doesn't work: when I submit the form, I get an Exception at 
BeanUtils.populate, because the list is not properly initialized. If 
I can't initialize it on the reset() method (I need to access the 
database), what else can I do?

Thanks in advance


-
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]


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


Problems initializing form objects

2004-12-13 Thread Diego Manilla Suárez
Hi! I have a problem with form members initialization.
I have this form.
public class BasicContentForm extends ValidatorForm {
   protected java.util.List propertyValues;
  
   public BasicContentForm() {
   this.propertyValues = new java.util.ArrayList();
   }
  
   public void setPropertyValues( java.util.List propertyValues ) {
   this.propertyValues = propertyValues;
   }   
  
   public java.util.List getPropertyValues() {
   return this.propertyValues;
   }
  
   public Object getPropertyValue(int index) {
   return propertyValues.get(index);
   }
  
   public void reset(ActionMapping mapping, HttpServletRequest request) {
   this.propertyValues = new java.util.ArrayList();
   }
}

And this jsp:




The problem is that the number and type of the elements of 
propertyValues list is calculated dynamically (from the database). I was 
doing that on my Action class, but I've realized that this doesn't work: 
when I submit the form, I get an Exception at BeanUtils.populate, 
because the list is not properly initialized. If I can't initialize it 
on the reset() method (I need to access the database), what else can I do?

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


html:form and modules

2004-11-08 Thread Diego
Hi! I have a modularized app here, and I'm having problems with
html:form tags. Is there a way to specify that the target action is on a
different module? Currently I'm forced to duplicate several action
mappings in the struts-config.xml files of my modules because I don't
know a way to do this.

Thanks in advance


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



Upload file size limit

2004-11-03 Thread Diego
Hi! I want to prevent the users from uploading files bigger than 1 MB,
so I've put this on my struts-config:



The problem is that, AFAIK, when the max file size is exceeded, the same
Action which receives the file is invoked with this attribute in the
request:

MultipartRequestHandler.ATTRIBUTE_MAX_LENGTH_EXCEEDED

The problem is that I'm using DispatchAction on my app, and when the
file size is exceeded, Struts is invoking my DispatchAction with no
arguments, so I get an error.

Do I have something wrong in my config or it's possible to change this
behaviour? I've thought of creating a "normal" Action to receive file
uploads, but I would want to avoid this, if possible.

Thanks in advance


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



Re: Multipart forms

2004-07-20 Thread Diego
Thanks again Niall. I had already put the code in my Action, as you suggested.
I'm using a DispatchAction with a somewhat large number of methods on it and
now I need to call my new method in several of them, this is why I would have
preferred this code in the reset(), but this way works fine.

regards,
Diego


>I can't think of anything you can do in Struts currently to get this to work
>in the "reset" method - all the relevant code is  in the
>RequestUtils.populate() method and we would have to refactor the multipart
>processing to resolve this (maybe you should open an enhacement request in
>bugzilla for it).
>
>Having said that, your code looks like it is doing whats needed to populate
>your checkbox values - can't you just move this code into the Action's
>execute method?
>
>Niall
>
>- Original Message - 
>From: "Diego" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Tuesday, July 20, 2004 8:26 AM
>Subject: Re: Multipart forms


> Thanks for your answer Niall. If I can't get the parameters in the reset()
> method, then I don't know how to solve my problem. My ActionForm is on
session
> and it's a wizard-like one. The jsp has tabs to go to any page at any
time.
> What I do with non-multipart forms is something like this in the reset()
> method:
>
> String page = request.getParameter("page");
> if (page != null && page.equals("1")) {
> String mycheckbox = request.getParameter("mycheckbox");
> //if mycheckbox==null,the user hasn't checked it->set the property to
N
> mycheckbox == null ? setMycheckbox("N") : setMycheckbox("Y");
> } else if (page != null && page.equals("2")) {
> ...
> }
>
> This works fine (I'm actually using multibox fields). I'm not using server
> validation in validate() method for several reasons, so I can't use it.
Any
> idea how can I do this with a multipart form?
>
> Thanks again.
>
> >You can't get them in the reset() method. Parameters in multipart
requests
> >are processed later and made available by wrapping the original request
in
> >MultipartRequestWrapper and  storing the "normal" request parameters in
that
> >wrapper. Thats not done until the form is populated. The first chance you
> >get to do anything is in the form's validate method.
>
> >Niall
>
> >- Original Message -
> >From: "Diego" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: Monday, July 19, 2004 3:26 PM
> >Subject: Fwd: Multipart forms
>
>
> >> Hi! I have a problem when I want to get some parameters in the reset()
> method
> >> of
> >> an ActionForm.
> >>
> >> If the form is a "normal" form, then I simply call
> >> request.getParameter("myparameter") and the parameter is retrieved with
no
> >> problem.
> >>
> >> But if the form is of type multipart, then I always get null. The
> parameter
> >> table seems to be filled later, on the RequestProcessor. I need to get
> >> parameters in the reset() method, specifically the "page" parameter, to
> deal
> >> with checkboxes in my wizard-style multipage form.
> >>
> >> How can I do it in the simplest way possible?
> >>
> >> Thanks in advance.
> >>
>
> 
> This message was sent using IMP, the Internet Messaging Program.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>



This message was sent using IMP, the Internet Messaging Program.


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



Re: Multipart forms

2004-07-20 Thread Diego
Thanks for your answer Niall. If I can't get the parameters in the reset()
method, then I don't know how to solve my problem. My ActionForm is on session
and it's a wizard-like one. The jsp has tabs to go to any page at any time.
What I do with non-multipart forms is something like this in the reset()
method:

String page = request.getParameter("page");
if (page != null && page.equals("1")) {
String mycheckbox = request.getParameter("mycheckbox");
//if mycheckbox==null,the user hasn't checked it->set the property to N
mycheckbox == null ? setMycheckbox("N") : setMycheckbox("Y");
} else if (page != null && page.equals("2")) {
...
}

This works fine (I'm actually using multibox fields). I'm not using server
validation in validate() method for several reasons, so I can't use it. Any
idea how can I do this with a multipart form?

Thanks again.

>You can't get them in the reset() method. Parameters in multipart requests
>are processed later and made available by wrapping the original request in
>MultipartRequestWrapper and  storing the "normal" request parameters in that
>wrapper. Thats not done until the form is populated. The first chance you
>get to do anything is in the form's validate method.

>Niall

>- Original Message -
>From: "Diego" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Monday, July 19, 2004 3:26 PM
>Subject: Fwd: Multipart forms


>> Hi! I have a problem when I want to get some parameters in the reset()
method
>> of
>> an ActionForm.
>>
>> If the form is a "normal" form, then I simply call
>> request.getParameter("myparameter") and the parameter is retrieved with no
>> problem.
>>
>> But if the form is of type multipart, then I always get null. The
parameter
>> table seems to be filled later, on the RequestProcessor. I need to get
>> parameters in the reset() method, specifically the "page" parameter, to
deal
>> with checkboxes in my wizard-style multipage form.
>>
>> How can I do it in the simplest way possible?
>>
>> Thanks in advance.
>>


This message was sent using IMP, the Internet Messaging Program.


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



Fwd: Multipart forms

2004-07-19 Thread Diego
Hi! I have a problem when I want to get some parameters in the reset() method
of
an ActionForm.

If the form is a "normal" form, then I simply call
request.getParameter("myparameter") and the parameter is retrieved with no
problem.

But if the form is of type multipart, then I always get null. The parameter
table seems to be filled later, on the RequestProcessor. I need to get
parameters in the reset() method, specifically the "page" parameter, to deal
with checkboxes in my wizard-style multipage form.

How can I do it in the simplest way possible?

Thanks in advance.




This message was sent using IMP, the Internet Messaging Program.


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



Problem with Apache and Tomcat integration

2004-06-23 Thread Diego


Hi! I'm having problems with Apache+Tomcat integration. I've configured Apache
to listen on port 7001 and Tomcat on 8080. The struts-example application works
fine, but  whenever I call an Action in my own application , the URL is changed
to port 8080 when that Action finishes (using
return(mapping.findForward("myforward"))). Every request that goes thru servlet
changes URL port to 8080.

I've compared my "forward" and "action" definitions in struts-config.xml with
the struts-example ones, and they seem identical. I've also compared both
web.xml files.

Does anyone know where the problem can be? Sorry, I don't post any
configuration
files here because I have no idea of which file is causing that behaviour. I
think the Apache-Tomcat connection is set up properly, because as I said, the
example application is working.

Thanks in advance. 


This message was sent using IMP, the Internet Messaging Program.


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



Problem with Apache and Tomcat integration

2004-06-23 Thread Diego


Hi! I'm having problems with Apache+Tomcat integration. I've configured Apache
to listen on port 7001 and Tomcat on 8080. The struts-example application works
fine, but  whenever I call an Action in my own application , the URL is changed
to port 8080 when that Action finishes (using
return(mapping.findForward("myforward"))). Every request that goes thru servlet
changes URL port to 8080.

I've compared my "forward" and "action" definitions in struts-config.xml with
the struts-example ones, and they seem identical. I've also compared both
web.xml files.

Does anyone know where the problem can be? Sorry, I don't post any
configuration
files here because I have no idea of which file is causing that behaviour. I
think the Apache-Tomcat connection is set up properly, because as I said, the
example application is working.

Thanks in advance. 


This message was sent using IMP, the Internet Messaging Program.


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



Multipage form and multibox fields

2004-05-19 Thread Diego


Hi everyone! I have a multi-page form with several multibox fields in its
different pages. The form is stored in session. In the ActionForm Javadoc I
found this:

--If the form is stored in session-scope so that values can be collected over
--multiple requests (a "wizard"), you must be very careful of which properties,
if
--any, are reset. As mentioned, session-scope checkboxes must be reset to false
--for any page where this property is set. This is because the client does not
--submit a checkbox value when it is clear (false). If a session-scoped
checkbox
--is not proactively reset, it can never be set to false.

Well, the problem I have is that I don't know how to do that. I mean, I know
where the reset() method is and I know how to set the multibox to false, but is
there a way to know what is the page number the user is going to? I just need to
reset the multibox fields that are on that page, if I've understood the text
above. The "page" field doesn't give me the page number I'm moving to, but the
previous one, I think.

Thanks in advance.


This message was sent using IMP, the Internet Messaging Program.


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



Complex validation

2004-04-15 Thread Diego
Hi everyone. I need to perform conditional validation in one of my forms. I have
a drop-down list and a text field. The validation applied to the text field
should be dependent on the value selected on the drop-down list. Is this
possible, using the Struts validator? I've taken a look at the "validwhen"
validator but I don't see how could this be done. I want a solution that allows
me to use Javascript validation.

Thanks in advance.


This message was sent using IMP, the Internet Messaging Program.


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