You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2006/10/26 20:18:43 UTC

Re: Integrating DWR and Struts2 for true "MVC" of snippets of web-pages

Don, is a Result Selector the same as this:

https://issues.apache.org/struts/browse/WW-1330

Frank


-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
 (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
 Supplying the wheel, so you don't have to reinvent it!

On Thu, October 26, 2006 1:58 pm, Don Brown wrote:
> Hmm...I don't see any of my replies in those two threads, but maybe
> there was more.  Anyways, I took a look at the DWR stuff, and it looks
> pretty cool.  My only concern is that is requires too much dwr
> configuration.  I wonder if there is a way we could push it into a
> plugin, that by simply dropping the plugin jar in WEB-INF/lib, you'd be
> good to go.  Whether this would mean overriding DWR's Configuration
> object to load config from a bundled dwr.xml file or even pushing the
> whole dwr servlet dispatcher into an action so that the user doesn't
> even need to modify web.xml, I don't know.  The goal would be seamless
> support from DWR without needing a multi-step configuration process, and
> without duplicate features such as type converters.
>
> Still, this doesn't solve the need for transparent JSON, XML, and
> partial HTML support.  I have an idea for that, which I'll spin off into
> another thread: Result Selectors.
>
> Don
>
> Alexandru Popescu wrote:
>> On 10/26/06, Don Brown <do...@gmail.com> wrote:
>>> Ah, those discussions after JavaOne:
>>>
>>> http://www.mail-archive.com/dev@struts.apache.org/msg22396.html
>>> http://www.mail-archive.com/dev@struts.apache.org/msg22381.html
>>>
>>> To be honest, I didn't really follow them at the time.
>>
>> Still, I remember you participating to the discussion :))
>>
>>> What code came out of it, other than the webwork dwr package?  If
>>> that code is for
>>> webwork, then I'd imagine it wouldn't work with Struts 2.
>>>
>>
>> As it is right now... no I don't think it will; but the changes should
>> be absolutely minimal.
>>
>> ./alex
>> --
>> .w( the_mindstorm )p.
>>
>>> Don
>>>
>>> On 10/25/06, Alexandru Popescu <th...@gmail.com>
>>> wrote:
>>> > On 10/26/06, Don Brown <mr...@twdata.org> wrote:
>>> > > Hmm...probably because I didn't know about it :)
>>> >
>>> > .... perhaps  :-)
>>> > > Should we move the code back into Struts 2?
>>> >
>>> > At some point I guess it may make sense to do this. For the moment
>>> > (and until it stabilizes and the struts2 stabilizes), I think it is
>>> > better for it out there.
>>> >
>>> > >  What exactly does it do?
>>> >
>>> > Simply put it allows you to call from DWR a normal action, passing
>>> > through its normal execution chain. The result can be the rendered
>>> > result (as in normal action invocations) or a serialized action
>>> object
>>> > (as in <ww:action executeResult="false" />).
>>> >
>>> > ./alex
>>> > --
>>> > .w( the_mindstorm )p.
>>> >
>>> > > Don
>>> > >
>>> > > Alexandru Popescu wrote:
>>> > > > Wille, I have contributed a long time ago some (similar?) code
>>> to DWR.
>>> > > > You can find it in the DWR trunk (a webwork package) . This
>>> > > > integration code is based on some work I initially done for
>>> InfoQ.com.
>>> > > >
>>> > > > Sure, if you find places where your ideas look better then my
>>> approach
>>> > > > I would be happy to hear from you and improve it. I am a bit
>>> puzzled
>>> > > > that Don haven't pointed you to this existing code, as the
>>> discussions
>>> > > > about where this code should live have been public by that time.
>>> > > >
>>> > > > ./alex
>>> > > > --
>>> > > > .w( the_mindstorm )p.
>>> > > >
>>> > > >
>>> > > > On 10/26/06, Wille Faler <wi...@infonatural.com> wrote:
>>> > > >> Hi.
>>> > > >> I raised the question today on Don Browns blog about being
>>> able to have
>>> > > >> integration between Struts2 and DWR, to get a full MVC model
>>> if you only
>>> > > >> want to re-render a snippet of a web-page.
>>> > > >> I am not sure if this has been discussed previously, but Don
>>> encouraged
>>> > > >> me to send my ideas if I had any, so here goes:
>>> > > >> When I have done AJAX-based stuff, 9 times out of 10, all I
>>> really want
>>> > > >> to do i execute some business logic, and re-render a portion
>>> of a page.
>>> > > >> This would seem to fit well with a traditional MVC-approach,
>>> with the
>>> > > >> exception that I don't want to re-render the full page.
>>> > > >>
>>> > > >> Earlier this year, I implemented such a simple framework,
>>> basically
>>> > > >> using Webwork2/XWork and DWR, adding some code to glue it all
>>> together.
>>> > > >> It consists of the following things:
>>> > > >> - Some generic JavaScript that can interpret parameters
>>> (either from a
>>> > > >> form or URL) into a Map of parameters, akin to what Webwork
>>> uses.
>>> > > >> - A Controller that is called by DWR, taking the Map, a
>>> callback-target
>>> > > >> (in the web-page) and the name of an action as its arguments.
>>> This
>>> > > >> Controller then invokes an xwork ActionProxy to invoke the
>>> Action.
>>> > > >> - Custom Result-implementations for getting JSP-elements
>>> defined in the
>>> > > >> xwork results. These results use the DWR
>>> > > >> WebContextFactory.get().forwardToString() functionality, to
>>> get the
>>> > > >> resulting JSP-snippet as a String.
>>> > > >> - Said Result can then be sent back by the Controller through
>>> DWR, which
>>> > > >> is then handled by generic JavaScript and rendered to the
>>> predefined
>>> > > >> callback-target on the page.
>>> > > >> - When using forms, it can also do AJAX-based validation which
>>> makes use
>>> > > >> of proper Xwork-validation.
>>> > > >>
>>> > > >> As I said, I have already written code for this, it is quite
>>> compact and
>>> > > >> only a few hundred lines (11 implementation classes + generic
>>> JavaScript
>>> > > >> + dwr config), so obviously this integration is quite easy to
>>> create. I
>>> > > >> would love to see something similar within the upcoming Struts2!
>>> > > >> I haven't attached the code to this mail, but it is available
>>> for
>>> > > >> download here: www.infonatural.com/ajax-mvc.zip (including
>>> > > >> jar-dependencies and some unit-tests, 3.6mb).
>>> > > >>
>>> > > >> If anyone wants to pick the code for ideas, or adapt it, feel
>>> free to do
>>> > > >> so as long as you retain the original @author comments as part
>>> of it (I
>>> > > >> am the sole copyright holder of the code, and you may use it
>>> under the
>>> > > >> ASF if you want).
>>> > > >> It would probably need some minor improvements to make it more
>>> in line
>>> > > >> with the rest of the Struts2-code (so tags work etc), as I
>>> only did the
>>> > > >> code originally for my needs and didn't bother doing more than
>>> I needed
>>> > > >> at the time.
>>> > > >>
>>> > > >> I apologise if this or something similar is already part of
>>> Struts2, but
>>> > > >> I got the impression that it may not be.
>>> > > >>
>>> > > >> regards
>>> > > >> Wille Faler
>>> > > >>
>>> > > >>
>>> > > >>
>>> ---------------------------------------------------------------------
>>> > > >> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> > > >> For additional commands, e-mail: dev-help@struts.apache.org
>>> > > >>
>>> > > >>
>>> > > >
>>> > > >
>>> ---------------------------------------------------------------------
>>> > > > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> > > > For additional commands, e-mail: dev-help@struts.apache.org
>>> > > >
>>> > > >
>>> > >
>>> > >
>>> > >
>>> ---------------------------------------------------------------------
>>> > > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> > > For additional commands, e-mail: dev-help@struts.apache.org
>>> > >
>>> > >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> > For additional commands, e-mail: dev-help@struts.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: dev-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>


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


Re: Integrating DWR and Struts2 for true "MVC" of snippets of web-pages

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Sounds cool!

Frank


Don Brown wrote:
> Not the same, but it enables the capability of WW-1330 in a more 
> transparent way to the Action.  My thought is first we should put the 
> plumbing in place to allow the selection of results outside the Action, 
> then we should start adding features that take advantage of that 
> capability.  WW-1330 is the prime example of a capability that would be 
> very easy to use if we had result selectors.
> 
> Don
> 
> Frank W. Zammetti wrote:
>> Don, is a Result Selector the same as this:
>>
>> https://issues.apache.org/struts/browse/WW-1330
>>
>> Frank
>>
>>
>>   
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM/Yahoo: fzammetti
MSN: fzammetti@hotmail.com
Author of "Practical Ajax Projects With Java Technology"
  (2006, Apress, ISBN 1-59059-695-1)
Java Web Parts - http://javawebparts.sourceforge.net
  Supplying the wheel, so you don't have to reinvent it!

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


Re: Integrating DWR and Struts2 for true "MVC" of snippets of web-pages

Posted by Don Brown <mr...@twdata.org>.
Not the same, but it enables the capability of WW-1330 in a more 
transparent way to the Action.  My thought is first we should put the 
plumbing in place to allow the selection of results outside the Action, 
then we should start adding features that take advantage of that 
capability.  WW-1330 is the prime example of a capability that would be 
very easy to use if we had result selectors.

Don

Frank W. Zammetti wrote:
> Don, is a Result Selector the same as this:
>
> https://issues.apache.org/struts/browse/WW-1330
>
> Frank
>
>
>   


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