You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Adam Ruggles <a....@gmail.com> on 2008/11/29 09:39:00 UTC

[S2] Handling input result on a CRUD action

I have a problem I'm trying to solve when the validation fails on a crud
action.  This action has add/create, edit/update, and list methods that all
get called correctly.  Now when the validation fails I have a list of items
that I need loaded.  Right now I have a prepareEdit and prepareAdd methods
that load this list on the initial load.  However when the validation fails,
for example on an update it calls the prepareUpdate.  I obviously do not
want to load the list on an update if the validation passes.

My question is, are there any good solutions to handle this?  Right now I'm
thinking either to detect the input result name in the prepareUpdate or
build an interceptor to handle this.  Anyone else run into this issue and
find a good solution?
-- 
View this message in context: http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Handling input result on a CRUD action

Posted by Adam Ruggles <a....@gmail.com>.
I agree with Dave as well. I ended up creating one interceptor and one
interface.  The interceptor registers a PreResultListener.  I then just
check for Action.INPUT in the result code.  If input is returned it will
call the prepareInputErrors method if it's available.

So far it works perfectly.


Burton Rhodes wrote:
> 
> Just read Dave's thought. Much better.
> 
> On 11/29/08, Burton Rhodes <bu...@gmail.com> wrote:
>> Just a thought but why don't put a redirect acrtion in your result
>> 'input' on your update action. That way if it fails it will run
>> prepareEdit.
>>
>> On 11/29/08, Adam Ruggles <a....@gmail.com> wrote:
>>>
>>> I have a problem I'm trying to solve when the validation fails on a crud
>>> action.  This action has add/create, edit/update, and list methods that
>>> all
>>> get called correctly.  Now when the validation fails I have a list of
>>> items
>>> that I need loaded.  Right now I have a prepareEdit and prepareAdd
>>> methods
>>> that load this list on the initial load.  However when the validation
>>> fails,
>>> for example on an update it calls the prepareUpdate.  I obviously do not
>>> want to load the list on an update if the validation passes.
>>>
>>> My question is, are there any good solutions to handle this?  Right now
>>> I'm
>>> thinking either to detect the input result name in the prepareUpdate or
>>> build an interceptor to handle this.  Anyone else run into this issue
>>> and
>>> find a good solution?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> --
>> Sent from my mobile device
>>
> 
> -- 
> Sent from my mobile device
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20765690.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Handling input result on a CRUD action

Posted by Burton Rhodes <bu...@gmail.com>.
Just read Dave's thought. Much better.

On 11/29/08, Burton Rhodes <bu...@gmail.com> wrote:
> Just a thought but why don't put a redirect acrtion in your result
> 'input' on your update action. That way if it fails it will run
> prepareEdit.
>
> On 11/29/08, Adam Ruggles <a....@gmail.com> wrote:
>>
>> I have a problem I'm trying to solve when the validation fails on a crud
>> action.  This action has add/create, edit/update, and list methods that
>> all
>> get called correctly.  Now when the validation fails I have a list of
>> items
>> that I need loaded.  Right now I have a prepareEdit and prepareAdd methods
>> that load this list on the initial load.  However when the validation
>> fails,
>> for example on an update it calls the prepareUpdate.  I obviously do not
>> want to load the list on an update if the validation passes.
>>
>> My question is, are there any good solutions to handle this?  Right now
>> I'm
>> thinking either to detect the input result name in the prepareUpdate or
>> build an interceptor to handle this.  Anyone else run into this issue and
>> find a good solution?
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> --
> Sent from my mobile device
>

-- 
Sent from my mobile device

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


Re: [S2] Handling input result on a CRUD action

Posted by Dave Newton <ne...@yahoo.com>.
--- On Sat, 11/29/08, Burton Rhodes <bu...@gmail.com> wrote:
> Just a thought but why don't put a redirect acrtion in your result 
> 'input' on your update action. That way if it fails it will run
> prepareEdit.

Under default circumstances you'd lose your error messages.

Dave


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


Re: [S2] Handling input result on a CRUD action

Posted by Burton Rhodes <bu...@gmail.com>.
Just a thought but why don't put a redirect acrtion in your result
'input' on your update action. That way if it fails it will run
prepareEdit.

On 11/29/08, Adam Ruggles <a....@gmail.com> wrote:
>
> I have a problem I'm trying to solve when the validation fails on a crud
> action.  This action has add/create, edit/update, and list methods that all
> get called correctly.  Now when the validation fails I have a list of items
> that I need loaded.  Right now I have a prepareEdit and prepareAdd methods
> that load this list on the initial load.  However when the validation fails,
> for example on an update it calls the prepareUpdate.  I obviously do not
> want to load the list on an update if the validation passes.
>
> My question is, are there any good solutions to handle this?  Right now I'm
> thinking either to detect the input result name in the prepareUpdate or
> build an interceptor to handle this.  Anyone else run into this issue and
> find a good solution?
> --
> View this message in context:
> http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

-- 
Sent from my mobile device

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


Re: [S2] Handling input result on a CRUD action

Posted by Adam Ruggles <a....@gmail.com>.
Do you think I would need to check the actionErrors/fieldErrors rather then
just check for the input return value?



newton.dave wrote:
> 
> You could just check to see if there are any errors before running the
> prepare logic; this could be done in an interceptor as well
> "prepareWhenErrors" or something.
> 
> Dave
> 
> --- On Sat, 11/29/08, Adam Ruggles <a....@gmail.com> wrote:
>> I have a problem I'm trying to solve when the validation
>> fails on a crud
>> action.  This action has add/create, edit/update, and list
>> methods that all
>> get called correctly.  Now when the validation fails I have
>> a list of items
>> that I need loaded.  Right now I have a prepareEdit and
>> prepareAdd methods
>> that load this list on the initial load.  However when the
>> validation fails,
>> for example on an update it calls the prepareUpdate.  I
>> obviously do not
>> want to load the list on an update if the validation
>> passes.
>> 
>> My question is, are there any good solutions to handle
>> this?  Right now I'm
>> thinking either to detect the input result name in the
>> prepareUpdate or
>> build an interceptor to handle this.  Anyone else run into
>> this issue and
>> find a good solution?
>> -- 
>> View this message in context:
>> http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
>> Sent from the Struts - User mailing list archive at
>> Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail:
>> user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20749650.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: [S2] Handling input result on a CRUD action

Posted by Dave Newton <ne...@yahoo.com>.
You could just check to see if there are any errors before running the prepare logic; this could be done in an interceptor as well "prepareWhenErrors" or something.

Dave

--- On Sat, 11/29/08, Adam Ruggles <a....@gmail.com> wrote:
> I have a problem I'm trying to solve when the validation
> fails on a crud
> action.  This action has add/create, edit/update, and list
> methods that all
> get called correctly.  Now when the validation fails I have
> a list of items
> that I need loaded.  Right now I have a prepareEdit and
> prepareAdd methods
> that load this list on the initial load.  However when the
> validation fails,
> for example on an update it calls the prepareUpdate.  I
> obviously do not
> want to load the list on an update if the validation
> passes.
> 
> My question is, are there any good solutions to handle
> this?  Right now I'm
> thinking either to detect the input result name in the
> prepareUpdate or
> build an interceptor to handle this.  Anyone else run into
> this issue and
> find a good solution?
> -- 
> View this message in context:
> http://www.nabble.com/-S2--Handling-input-result-on-a-CRUD-action-tp20745023p20745023.html
> Sent from the Struts - User mailing list archive at
> Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail:
> user-help@struts.apache.org


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