A robust starter web application to ease Java webapp development.

Home | Tutorials | Demos | Issues

 « Return to Thread: Ajax?

Re: Ajax?

by felipenasc :: Rate this Message:

Reply to Author | View in Thread

I dont know if there is a tutorial. If not, you can write one with
your experience and everybodies tips, and then, I guess, send it to
Matt so he add it to the wiki (right Matt?).

In my opinion, you have two good options in Appfuse:

1) DWR
This is good when you want to get javascript objects from Java and vice-versa.
DWR is already configured in web.xml so you call its servlet. the url
pattern used is "/dwr/*".
If you want to integrate it with your Spring config, you can do:
- in your action-servlet.xml, add a url mapping to your urlMapping
bean like this (add it after all the others):
<prop key="/**/*">dwrController</prop> (dont know if this the best,
but it works).

- define your dwrController:
        <bean id="dwrController"
class="org.springframework.web.servlet.mvc.ServletWrappingController">
                <property name="servletClass">
                        <value>uk.ltd.getahead.dwr.DWRServlet</value>
                </property>
                <property name="initParameters">
                        <props>
                                <prop key="debug">false</prop>
                        </props>
                </property>
        </bean>

- configure your WEB-INF/dwr.xml
<dwr>
        <allow>
                <convert converter="bean" match="br.com.facio.progenda.model.*" />
               
                <create creator="spring" javascript="DwrManager">
                        <param name="beanName" value="dwrManager" />
                </create>
        </allow>
</dwr>

- I created a DWRManager in applicationContext-service.xml:
    <bean id="dwrManager" parent="txProxyTemplate">
        <property name="target">
            <bean
class="br.com.facio.progenda.service.impl.DWRManagerImpl"
autowire="byName" />
        </property>
        <property name="transactionAttributes">
            <props>
                <prop key="*">PROPAGATION_REQUIRED,readOnly</prop>
            </props>
        </property>
    </bean>

- Now, you can play with it by creating methods in this DWRManager and
calling them from your javascript code, lke this:
<script>
function test(){
        DwrManager.getPerson(_replyPerson, document.getElementById('personId').value);
}

var _replyPerson = function(person){
        alert("The person name is:" + person.name);
}
</script>


2) Script.aculo.us
This is very nice. If you want, for example, to update a content of a
div with html code received from the server, use scriptsaculous
Ajax.Updater. There is nothing to confire. This will only request your
server as it was a normal request, receiving a response that your
controller flushes (html, xml, whatever).



Felipe

2006/2/24, Thomas Gaudin <thogau@...>:

> There are already some ajax stuff integrated in Appfuse (dwr,
> scriptaculous, prototype...).
> By integrated, I mean everything is configured so that you can use those
> libraries.
> So it is up to you to decide what you want to do with ajax, here are
> some places where you may get inspiration :
> http://getahead.ltd.uk/dwr/examples
> http://wiki.script.aculo.us/scriptaculous/show/Demos
> http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html
> There is a very trivial example of how to use dwr in the facelet
> prototype (on the main menu page) :
> http://www.thogau.net/appfuse-facelets/mainMenu.html
> Hope it helps,
>
> Thomas
>
>
>
> David_Wang@... a écrit :
> > I want to try Ajax with AppFuse 1.9. Are there any examples or tutorials
> > with AppFuse for a new Ajax developer?
> >
> >
> > ======================================================================
> > Confidentiality Notice: The information contained in and transmitted with this communication is strictly confidential, is intended only for the use of the intended recipient, and is the property of Countrywide Financial Corporation or its affiliates and subsidiaries.  If you are not the intended recipient, you are hereby notified that any use of the information contained in or transmitted with the communication or dissemination, distribution, or copying of this communication is strictly prohibited by law..  If you have received this communication in error, please immediately return this communication to the sender and delete the original message and any copy of it in your possession.
> > ======================================================================
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@...
> > For additional commands, e-mail: users-help@...
> >
> > ---------------------------------------------------------------------------------------
> > Wanadoo vous informe que cet  e-mail a ete controle par l'anti-virus mail.
> > Aucun virus connu a ce jour par nos services n'a ete detecte.
> >
> >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Ajax?