Transactions in Actions

2003-03-07 Thread Stefan Arentz
Question about using EJBs from an Action. I tried creating a 
UserTransaction like this:

 try
 {
   UserTransaction transaction = (UserTransaction)
 initialContext.lookup("java:/comp/UserTransaction");
   transaction.begin();
   .. do work with a stateless session bean ..

   if error throw new SystemException();

   transaction.commit();
  }
  catch (SystemException e)
  {
 ...
  }
But this throws a NestedTransactionException.

I am running this in JBoss with Jetty.

 S.

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


Re: GET/POST in Actions & Form Validation

2003-03-07 Thread Stefan Arentz
On Friday, Mar 7, 2003, at 15:13 Europe/Amsterdam, [EMAIL PROTECTED] 
wrote:

You can set validate="false" and call the validation method from 
action if you
would..
try it.
Ah! Good advise. I didn't think of that :-/

I also got it to work with an extra action where validation was set to 
false, but doing the validation programatically is much nicer.

Thanks!

 S.

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


GET/POST in Actions & Form Validation

2003-03-07 Thread Stefan Arentz
Hi,

This is my first web app with Struts, so please be gentle :-)

I am trying to implement the following pattern:

 On GET:

  - Populate a form with fields OR show an empty form
  - Show the form
 On POST:

  - Validate the form, show it again if it has errors.

Very basic, but yet, I can't find the correct way to do this with 
Struts.

I have not seen one piece of example code that looks at the request 
method to make the distinction between showing the initial empty form 
(GET) or processing it (POST).

In my code I do basically this:

 execute()
 {
if (request.getMethod().compareTo("GET") == 0)
{
   ... code to setup the session ...
   return mapping.findForward("AddRecord"); // Shows the form
}
if (request.getMethod().compareTo("POST") == 0)
{
   ... execute some business logic ...
   return mapping.findForward("Success"); // Goes back to were we 
came from
}
  }

But the problem here is that when I forward to the AddRecord forward, 
the form is validated, which in case of an empty initial form will show 
errors for each field. I can set validate to false in my action 
definition but then validation is also skipped when I need it.

The forward is defined like this:

  

This must be very basic, but it is very difficult to find a clear 
answer in the large amount of Struts related resources :-/

 S.

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


Re: Can't retrieve definition for form null

2002-10-03 Thread Stefan Arentz

On Wed, Oct 02, 2002 at 10:54:21PM -0400, Doug Dates wrote:
> I tried  and , I got
> same error. I guess I am trying to call the form with a null value. But I
> can't understand in which case, form can be null.

Are you sure your form bean class is included in your project? Try
setting the Struts debug level higher so that you can see at least
a stack trace in your container's log.

 S.


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Struts 101 - How to create a button that links to an action

2002-10-02 Thread Stefan Arentz

Thanks for the quick reply!

Hmmm ok that seems to work but when I look in the ActionConfig javadoc,
I see this for the name attribute:

  Name of the form bean, if any, associated with this Action.

Shouldn't Struts have that dummy form built in? And refer to that
automatically when the name is empty?

I forgot to mention that I'm using 1.1b2.

 Stefan

On Thu, Oct 03, 2002 at 11:19:42AM +1000, Steve Vanspall wrote:
> You need to define the name attribute for your action mapping.
> 
> 
>  name="MyForm" scope="request"/>
>   
> 
> and MyForm needs to be defined in the form-beans section of your
> struts-config file.
> 
> e.g.
> 
> 
> 
> 
> 
> or something similar.
> 
> This can be a dummy form you make up that has no fields.
> 
> then it should go to the action properly
> 
> 
> 
> - Original Message -
> From: "Stefan Arentz" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, October 03, 2002 11:09 AM
> Subject: Struts 101 - How to create a button that links to an action
> 
> 
> > I'm really strugling with some simple things that I know how to solve
> > with 'plain html' but not with the Struts framework.
> >
> > One of those things is this, I need a simple button that links to a
> > specific action. There are no form elements, just a button.
> >
> > I tried this:
> >
> >  
> >
> >  
> >
> > with:
> >
> >   
> >  scope="request"/>
> >   
> >
> > But this bails out with a 'Cannot retrieve definition for form bean'.
> >
> > Can someone give this newbie a hint :-)
> >
> >  Stefan
> >
> >
> > --
> > To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> >
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

-- 
[EMAIL PROTECTED] / http://www.soze.com/stefan
"Think of Your cellular phone as a party line", Ian Goldberg 


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




Struts 101 - How to create a button that links to an action

2002-10-02 Thread Stefan Arentz

I'm really strugling with some simple things that I know how to solve
with 'plain html' but not with the Struts framework.

One of those things is this, I need a simple button that links to a
specific action. There are no form elements, just a button.

I tried this:

 
   
 

with:

  

  

But this bails out with a 'Cannot retrieve definition for form bean'.

Can someone give this newbie a hint :-)

 Stefan


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Help required on Digester class

2002-05-01 Thread Stefan Arentz


On Wednesday, May 1, 2002, at 08:23  PM, Craig R. McClanahan wrote:

...

>> Yup. This works fine. Digester is a great tool! One thing I'm looking 
>> at
>> is how to combine it with a set of regular expression rules for the
>> elements and attributes. Something like:
>>
>>   
>> 
>>   
>>
>> With a property list:
>>
>>   command.id=/^\d+$/
>>   user.username=/^[a-z0-9]+$/
>>
>> And make this part of the validation process. I'm interested in your
>> thoughts about this. Is this something to add to the Digester core code
>> or something that I should move to my own classes?
>>
>
> Do you mean that you want to ensure that the attributes match those
> patterns?  Personally, I think that's a little out of scope for 
> Digester,
> although you could probably do it by implementing your own matching
> algorithm in an org.apache.commons.digester.Rules implementation (either
> don't select the rules on mismatched patterns, or throw an exception or
> something).  Another alternative would be to throw an exception in the
> property setter of the beans being created.

Hmm. I had not thought about the property setter. My problem is that I 
need to give feedback to the user about where exactly in the XML 
document the wrong input was given. Preferably with a line number. Is 
there a way to get that information from the parser, or is all that 
logic buried deep in the Digester class?

  Stefan


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




Re: Help required on Digester class

2002-05-01 Thread Stefan Arentz


On Tuesday, April 30, 2002, at 05:24  PM, Craig R. McClanahan wrote:

>
>
> On Tue, 30 Apr 2002, Vijay Arokayaraj wrote:
>
>> Date: Tue, 30 Apr 2002 05:18:39 -0700
>> From: Vijay Arokayaraj <[EMAIL PROTECTED]>
>> Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]>,
>>  [EMAIL PROTECTED]
>> To: [EMAIL PROTECTED]
>> Subject: Help required on Digester class
>>
>> Hi all,
>> I am new to struts. My question is do we have to use the Digester 
>> class to actually read any of the XML files? If so how do I actually 
>> map an XML file into a class object (class here represents a model) 
>> when the XML file has got multiple elements in them and is not 
>> attribuite oriented . For example
>>
>> 
>>   
>> vijay
>>  [EMAIL PROTECTED]
>>
>>
>
> One way to do this would be to define a Digester rule for each nested
> property name:
>
>   digester.addObjectCreate("user", "com.mycompany.MyUserClass");
>   digester.addCallMethod("user/name", "setName", 0);
>   digester.addCallMethod("user/mail", "setMail", 0);

Yup. This works fine. Digester is a great tool! One thing I'm looking at 
is how to combine it with a set of regular expression rules for the 
elements and attributes. Something like:

  

  

With a property list:

  command.id=/^\d+$/
  user.username=/^[a-z0-9]+$/

And make this part of the validation process. I'm interested in your 
thoughts about this. Is this something to add to the Digester core code 
or something that I should move to my own classes?

  Stefan


--
To unsubscribe, e-mail:   
For additional commands, e-mail: