You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Burton Rhodes <bu...@gmail.com> on 2012/06/08 16:03:05 UTC

How to organize "regular" Actions and "ajax/json" Actions

I have a web application that originally mapped only one action per
page (for the most part).  Little by little it's grown to incoporate
ajax/json actions (using Struts json plugin) that populate different
parts of pages or update the database.  My question is how best to
organize these new actions in packages with the rest of the web
application. First I started with a simple json package, but realized
this probably isn't manageable as I add more "json" actions.  Then I
thought to move these "json" actions in with other packages but
hesistate since they tend to span multiple pages. Or perhaps this is
the best way and use a naming convension for these, e.g.
ContactJsonAction.java ??

Just curious if any of you have found a good way to do this and stay
logical and organized...

My current layout is something like:
com.afs.web.action
 - com.afs.web.action.contact
 - com.afs.web.action.accounts
 - com.afs.web.action.xactions
 - com.afs.web.action.help
 - com.afs.web.action.json             <-- this is a catch-all for json actions
 - ....

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


Re: How to organize "regular" Actions and "ajax/json" Actions

Posted by Burton Rhodes <bu...@gmail.com>.
Yes... you are right.

I guess what I meant by "spanning multiple pages" is that up until now
all my actions classes mapped nicely to my /webapp/struts/ (jsp)
directory structure. (e.g.
/java/com/afs/web/action/contact/ContactDetailAction.java  =>
/webapp/struts/contact/contactDetail.jsp).  Now I have json actions
that are used by jsps (via client side js) that reside in various
/webapp/struts/ directories.  But as you suggested, I need to think of
my action packages from a functionality standpoint rather than from a
website directory/layout perspective.

I think I will end up moving them to the appropriate functional
package perhaps with a naming convention of adding "Json" somewhere in
the name (e.g. ContactJsonAction.java).

On Fri, Jun 8, 2012 at 9:05 AM, Dave Newton <da...@gmail.com> wrote:
> I wouldn't have a package just for "JSON actions", because that separates
> them from what they actually are.
>
> I'm not sure what is meant by "spanning multiple pages"; in general
> wouldn't they still be associated with specific data types, or
> functionality?
>
> Dave
>
> On Fri, Jun 8, 2012 at 10:03 AM, Burton Rhodes <bu...@gmail.com>wrote:
>
>> I have a web application that originally mapped only one action per
>> page (for the most part).  Little by little it's grown to incoporate
>> ajax/json actions (using Struts json plugin) that populate different
>> parts of pages or update the database.  My question is how best to
>> organize these new actions in packages with the rest of the web
>> application. First I started with a simple json package, but realized
>> this probably isn't manageable as I add more "json" actions.  Then I
>> thought to move these "json" actions in with other packages but
>> hesistate since they tend to span multiple pages. Or perhaps this is
>> the best way and use a naming convension for these, e.g.
>> ContactJsonAction.java ??
>>
>> Just curious if any of you have found a good way to do this and stay
>> logical and organized...
>>
>> My current layout is something like:
>> com.afs.web.action
>>  - com.afs.web.action.contact
>>  - com.afs.web.action.accounts
>>  - com.afs.web.action.xactions
>>  - com.afs.web.action.help
>>  - com.afs.web.action.json             <-- this is a catch-all for json
>> actions
>>  - ....
>>
>> ---------------------------------------------------------------------
>> 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


Re: How to organize "regular" Actions and "ajax/json" Actions

Posted by Dave Newton <da...@gmail.com>.
I wouldn't have a package just for "JSON actions", because that separates
them from what they actually are.

I'm not sure what is meant by "spanning multiple pages"; in general
wouldn't they still be associated with specific data types, or
functionality?

Dave

On Fri, Jun 8, 2012 at 10:03 AM, Burton Rhodes <bu...@gmail.com>wrote:

> I have a web application that originally mapped only one action per
> page (for the most part).  Little by little it's grown to incoporate
> ajax/json actions (using Struts json plugin) that populate different
> parts of pages or update the database.  My question is how best to
> organize these new actions in packages with the rest of the web
> application. First I started with a simple json package, but realized
> this probably isn't manageable as I add more "json" actions.  Then I
> thought to move these "json" actions in with other packages but
> hesistate since they tend to span multiple pages. Or perhaps this is
> the best way and use a naming convension for these, e.g.
> ContactJsonAction.java ??
>
> Just curious if any of you have found a good way to do this and stay
> logical and organized...
>
> My current layout is something like:
> com.afs.web.action
>  - com.afs.web.action.contact
>  - com.afs.web.action.accounts
>  - com.afs.web.action.xactions
>  - com.afs.web.action.help
>  - com.afs.web.action.json             <-- this is a catch-all for json
> actions
>  - ....
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>