RE: How to cancel a cancel

2005-07-23 Thread Kent Boogaart
Actually, it turned out to be a bit harder than that. *sigh*

Here's how I've solved my problem (basically):

1. Implement a base action which overrides the cancelled() method

2. In the override, check whether the request is cancelled. If so, look for
a forward and clear the cancellation. Return the forward.

3. Subclass my base action from any cancelable action and include a cancel
forward in the config for that cancelable action.

If anyone wants code, I can post.

Cheers,
Kent

-Original Message-
From: Kent Boogaart [mailto:[EMAIL PROTECTED] 
Sent: Saturday, 23 July 2005 12:07 PM
To: 'Struts Users Mailing List'
Subject: RE: How to cancel a cancel

Thanks for the suggestions guys. I stared at this one a bit longer and this
is what I came up with...I put this code in my action class:

@Override
public ActionForward cancelled(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward(FORWARD_CANCELLED);
}

And my config file just defines the cancelled action with a forward back to
page 2.

By default this method returns null, which resulted in my save dispatch
method being called, which had the special code to handle cancelling.
However, the cancel flag wasn't being cleared.

Now it does what I want it to do - submits back to form 2 and *clears the
cancelled flag*. To be honest, I don't know why the cancel flag is being
cleared now but it certainly is.

As a final note, I had already tried using a forward instead of a submit but
that didn't work for me because form 3 had data in it that form 2 required
in order to display.

Thanks,
Kent

-Original Message-
From: Michael Jouravlev [mailto:[EMAIL PROTECTED] 
Sent: Saturday, 23 July 2005 1:08 AM
To: Struts Users Mailing List
Subject: Re: How to cancel a cancel

On 7/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 Kent Boogaart wrote the following on 7/22/2005 5:49 AM:
 
  My actions for pages 2 and 3 have code like this in them:
 
  if (isCancelled(request)) {
  return mapping.findForward(FORWARD_CANCELLED);
  }
 
  My question is: is this the normal way to do it? If so, is there an easy
/
  nice way to reset the cancel flag. I understand I could just remove a
  request parameter but I want to make sure I'm doing this the best way.
 
 I'm really not sure of the 'best' way and I'm probably not doing it the
 'standard' way, but since I like to manually call validate from my
 Actions, I just treat 'cancel' like I would any other form submit. (The
 only benefit to the html:cancel tag (I think:) is that it allows you to
 submit the page without having validate() called.)
 
 Since I like dispatch actions, I just pass the dispatch parameter
 cancel and then I process it how I want in the action in my cancel
 dispatch method. Sometimes, when I know the user can only get to the
 page from a certain flow it allows me to call my prep() method and prep
 the reulting page with whatever it needs for display.

I second that approach. Instead that I use redirect instead of
forward, so all request parameters including Cancel are cleared
automatically.

It may make sense to build each page as a dialog. Or even to create a
wizard out of three pages.

--
Struts Dialogs
http://struts.sourceforge.net/strutsdialogs



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



How to cancel a cancel

2005-07-22 Thread Kent Boogaart
Hi,

I have a form that can be cancelled via an html:cancel button. When it
cancels it submits back to its parent action. The problem is, the parent
action can also be cancelled and so it thinks it has been cancelled and
submits back to its parent in turn.

Maybe some ASCII art will help. This is how it is supposed to work:

Page 1 --- Page 2 --- Page 3
^   |^   |
Cancel--+Cancel--+

This is what is actually happening when I cancel from page 3:

Page 1 --- Page 2 --- Page 3
^|
+---Cancel---+

It is skipping past page 2 because page 2 thinks it has been cancelled too.

My actions for pages 2 and 3 have code like this in them:

if (isCancelled(request)) {
return mapping.findForward(FORWARD_CANCELLED);
}

My question is: is this the normal way to do it? If so, is there an easy /
nice way to reset the cancel flag. I understand I could just remove a
request parameter but I want to make sure I'm doing this the best way.

Thanks,
Kent


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



RE: How to cancel a cancel

2005-07-22 Thread Kent Boogaart
Thanks for the suggestions guys. I stared at this one a bit longer and this
is what I came up with...I put this code in my action class:

@Override
public ActionForward cancelled(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
return mapping.findForward(FORWARD_CANCELLED);
}

And my config file just defines the cancelled action with a forward back to
page 2.

By default this method returns null, which resulted in my save dispatch
method being called, which had the special code to handle cancelling.
However, the cancel flag wasn't being cleared.

Now it does what I want it to do - submits back to form 2 and *clears the
cancelled flag*. To be honest, I don't know why the cancel flag is being
cleared now but it certainly is.

As a final note, I had already tried using a forward instead of a submit but
that didn't work for me because form 3 had data in it that form 2 required
in order to display.

Thanks,
Kent

-Original Message-
From: Michael Jouravlev [mailto:[EMAIL PROTECTED] 
Sent: Saturday, 23 July 2005 1:08 AM
To: Struts Users Mailing List
Subject: Re: How to cancel a cancel

On 7/22/05, Rick Reumann [EMAIL PROTECTED] wrote:
 Kent Boogaart wrote the following on 7/22/2005 5:49 AM:
 
  My actions for pages 2 and 3 have code like this in them:
 
  if (isCancelled(request)) {
  return mapping.findForward(FORWARD_CANCELLED);
  }
 
  My question is: is this the normal way to do it? If so, is there an easy
/
  nice way to reset the cancel flag. I understand I could just remove a
  request parameter but I want to make sure I'm doing this the best way.
 
 I'm really not sure of the 'best' way and I'm probably not doing it the
 'standard' way, but since I like to manually call validate from my
 Actions, I just treat 'cancel' like I would any other form submit. (The
 only benefit to the html:cancel tag (I think:) is that it allows you to
 submit the page without having validate() called.)
 
 Since I like dispatch actions, I just pass the dispatch parameter
 cancel and then I process it how I want in the action in my cancel
 dispatch method. Sometimes, when I know the user can only get to the
 page from a certain flow it allows me to call my prep() method and prep
 the reulting page with whatever it needs for display.

I second that approach. Instead that I use redirect instead of
forward, so all request parameters including Cancel are cleared
automatically.

It may make sense to build each page as a dialog. Or even to create a
wizard out of three pages.

--
Struts Dialogs
http://struts.sourceforge.net/strutsdialogs


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



c:if and dyna form bean

2005-07-20 Thread Kent Boogaart
Hi people,

I have a simple question for you. I'm trying to use a dynaform bean from
within a c:if like this:

bean:define id=form name=userform/

c:if test=${form.displayName == true}
...
/c:if

I'm getting an exception telling me Unable to find a value for
'displayName' in object of class  I understand this is to do with how
dynaforms work. There is indeed no method called getDisplayName() on my form
bean but there definitely is a form-property called displayName. So how
would I go about using this form-property of the dynaform from a c:if?

Thanks,
Kent


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



Using the form bean

2005-07-08 Thread Kent Boogaart
Hello,

I'm trying to set focus on the first enabled field in my form. The first
field is disabled if the data is being edited. I thought this would work:


bean:define id=form name=configuration.user/
bean:define id=focus value=userName/

logic:equal name=form property=edit scope=request value=true
bean:define id=focus value=password/
/logic:equal

html:form action=/configuration/user_save focus=${focus}


But this complains about No bean found under attribute key form. The weird
thing is, I use that same bean further down the page without any problem:


html:text property=userName readonly=${form.edit}
disabled=${form.edit/


If I take out the logic:equal code then it works (but doesn't set focus to
the password field when required). What am I doing wrong here?

Thanks,
Kent


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



RE: Using the form bean

2005-07-08 Thread Kent Boogaart
Thanks Abdullah, I took the JSP 2.0 approach. Didn't realize that was
possible. The c:if kind of worked but I wasn't able to put the
bean:define inside it (it printed out static text though so it was
obviously working).

Thanks again,
Kent

-Original Message-
From: Abdullah Jibaly [mailto:[EMAIL PROTECTED] 
Sent: Friday, 8 July 2005 11:53 PM
To: Struts Users Mailing List
Subject: RE: Using the form bean

Don't know if this is the reason but you probably want focus=${focus}

Try using c:if instead of logic:equal, but the cleanest way if you are using
jsp 2.0:

focus=${form.edit ? 'password' : 'userName'}

Regards,
Abdullah

-Original Message-
From: Kent Boogaart [mailto:[EMAIL PROTECTED]
Sent: Friday, July 08, 2005 7:59 AM
To: 'Struts Users Mailing List'
Subject: Using the form bean


Hello,

I'm trying to set focus on the first enabled field in my form. The first
field is disabled if the data is being edited. I thought this would work:


bean:define id=form name=configuration.user/
bean:define id=focus value=userName/

logic:equal name=form property=edit scope=request value=true
bean:define id=focus value=password/
/logic:equal

html:form action=/configuration/user_save focus=${focus}


But this complains about No bean found under attribute key form. The weird
thing is, I use that same bean further down the page without any problem:


html:text property=userName readonly=${form.edit}
disabled=${form.edit/


If I take out the logic:equal code then it works (but doesn't set focus to
the password field when required). What am I doing wrong here?

Thanks,
Kent


-
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: Refresher for newbies (part 2)

2005-07-07 Thread Kent Boogaart
Thanks Rick for the example. It has really helped me as I am certainly a
noob.

I'd love it if you (or anyone) could clarify something for me. Firstly, some
basic info on my system: I have system wide settings including an SMTP
server and a list of users that can access the system. These are stored in a
SystemSettings class.

I took your advice and used a DispatchAction for system-related updates. I
called it SystemAction. It contains 2 methods: setUpForEdit() and edit(). My
related form bean contains a dispatch property which defaults to
setUpForEdit. This seems to work fine.

My system configuration JSP lists users in a select box. Your example lists
users as static text with an edit link for each user. This allows you to use
c:url  to figure include the user ID. However, I have one edit link next
to my select box.

I understand I have to use javascript to set the user ID and then submit /
forward to my user JSP. My questions are:

1. Is there some standard way of handling this with struts / other tag
libraries?

2. Assuming not, I would like to develop my own (I will have a lot of select
boxes with add / edit / delete links alongside them in my application).
Would this be possible, given the reliance on embedding javascript and
knowing what parameters to pass to the target page?

I know these are kind of general questions but I'm finding it hard to be
more specific since I am such a noob. Hopefully you'll be able to confirm
that what I'm attempting to do is fairly common and maybe point me in the
right direction.

Thanks,
Kent


-Original Message-
From: Rick Reumann [mailto:[EMAIL PROTECTED] 
Sent: Friday, 8 July 2005 1:45 AM
To: Struts Users Mailing List
Subject: Re: Refresher for newbies (part 2)

After reading the initial newbie post, you then might come across a 
situation where you need to have some things like lists on the page 
that aren't related to your ActionForm. For example, in the User example 
just given, imagine you need the person using the form to select a 
Department that the user belongs in. You thus need a way to make sure 
that a List of department is available on the page for the user to 
select from.

Now before we get a ton of responses about how here's why I came up 
with this for Struts, and here's my solution..., I understand that many 
of the ideas that many of you have come up with our very ingenious and 
very practical once you understand the framework. I believe, however, 
for someone new to Struts that it's better to Keep Things Simple and 
keep things fairly consistent with what they are used to. For this 
reason I suggest you do things this way

In your DispatchAction simply provide a prep( HtttpServletRequest 
request) method.

In there you simply do any preparation of things your form might need. 
*NOTE* *NOTE* NOTE*: This is NOT, NOT, NOT where you do things like 
populate the form with user information etc. This is only where you 
would do things like provide lists for drop down so they are in scope.

The next more advanced question is well what happens if you are using 
validation and validation fails, how are these going to be in scope?

I believe the answer is quite simple... just call validate from your 
Action class versus relying on Struts to call it based on your struts 
config setting!

I have more on this here 
http://www.reumann.net/struts/articles/request_lists.jsp

The benefit to the prep() and the calling validate manually is 
everything is quite simple... you are using a standard DispatchAction 
which is easy for people to understand PLUS everything is all in one 
place. When dealing with editing Users you can look in your 
UserDispatchAction and see what's going on. No need to look at a bunch 
of xml config settings, AspectJ inserts, or some other hidden stuff.

Granted yes, the newer frameworks handle all of this more gracefully, 
but the problem is not that big of a deal with Struts. I've written 
some pretty complex applications and the above has been working fine and 
it becomes so simple to do.

-- 
Rick


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



Struts and Generics

2005-07-06 Thread Kent Boogaart
Hi there,

I'm wondering whether it's possible to use generics with struts. Something
like:

form-bean name=test type=org.apache.struts.validator.DynaValidatorForm
form-property name=users
type=java.util.ArrayListtestpackage.User/
/form-bean

I tried doing this (with my class names of course) and I get this exception
on startup:
javax.servlet.ServletException: Can't get definitions factory from
context.

Thanks,
Kent


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



Question re html:select on the client

2005-07-06 Thread Kent Boogaart
Hello,

I have an html:select populated from a collection. Alongside the select box
I have links to add, edit and delete items. I'm just wondering what the best
way is to handle passing the ID of the selected item to the edit and delete
actions.

For example, if the user selects the option with value 12, I'd like to
forward to something like /editAction?id=12. Is there some way to tell the
html:link tag to dynamically construct the querystring on the client?

Thanks,
Kent


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