Copy <project root>\web\target\work\webapp\decorators\default.jsp to web/src/main/webapp/decorators/default.jsp and you should be good to go - this will override all others.
Matt On Thu, Mar 19, 2009 at 7:15 AM, jackalista <j...@twaxx.com> wrote: > > Hi AppFuse people, > > I'm trying to follow the Ajax tutorial [at: > http://appfuse.org/display/APF/Ajax] using a *modular* struts2 project and > am trying to figure out which version of several files I need to make the > recommended changes in. The tutorial step I'm having trouble with is: > > 1b) make sure the dojo files are imported first. > To do this open your /src/main/webapp/decoraters/default.jsp file and add > this line above! all other js imports: > <s:head theme="ajax" debug="true"/> > > The problem is there's no decorators folder in my <project > root>/web/src/main/webapp folder [this is a modular project]. There *are* > several decorators folders [4, to be exact] in my project and they all have > a default.jsp but they're all under target, I feel like I'm missing > something here. Here are the decorators folders, and hence the default.jsp, > which one do I use? > > <project root>\web\target\supplierportal-webapp-1.0-SNAPSHOT\decorators > <project root>\web\target\work\webapp\decorators > <project root>\web\target\war\work\appfuse-struts-2.0.2\decorators > <project root>\web\target\war\work\appfuse-web-common-2.0.2\decorators > > I'm confused by the fact that these are all under target, shouldn't there be > a version under <project root>\web\src as specified in the tutorial > instructions? Does some jar need to be extracted or what is going on here? > > > > > > > > > mraible wrote: >> >> What do you think about re-writing this tutorial in an AppFuse >> environment and seeing if we make it simpler? >> >> Matt >> >> On 9/13/07, tibi <t...@dds.nl> wrote: >>> i would like to add this to the tutorial page: >>> >>> please eval..... >>> >>> tibi >>> >>> -------------------------------------------------------------------------------------------------------- >>> >>> this part is an extension on the following fine tutorial: >>> http://cwiki.apache.org/S2WIKI/struts-2-spring-2-jpa-ajax.html >>> take care the tutorial does not do anything apart from demonstrating the >>> working of ajax. the java code is prototype only. >>> >>> this tutorial misses out on 3 things: >>> 1a) integration it within appfuse setup, taking care of the dojo files >>> 1b) integration it within appfuse setup, taking care of the importing >>> order of the js files >>> 2) getting it working with the decorator, or better without ;) >>> >>> 1a) the dojo files can't be run from the sturts.jar file. >>> >>> to solve this open the struts2-core-2.0.6.jar >>> copy the dojo folder into >>> src/main/webapp/struts/dojo >>> >>> open your web.xml and make sure the staticFIlter is including the right >>> folder: >>> <filter> >>> <filter-name>staticFilter</filter-name> >>> >>> <filter-class>org.appfuse.webapp.filter.StaticFilter</filter-class> >>> <init-param> >>> <param-name>includes</param-name> >>> <param-value>/struts/dojo/*</param-value> >>> </init-param> >>> </filter> >>> >>> 1b) make sure the dojo files are imported first. >>> to do this open your /src/main/webapp/decoraters/default.jsp file and >>> add this line above! all other js imports: >>> <s:head theme="ajax" debug="true"/> >>> >>> (otherwise it will conflict with atleast the scriptaculous.js) >>> >>> 2) make sure your ajax return string will not be decorated. >>> there are many option but i like to do this: >>> open your decorators.xml file: >>> <decorators defaultdir="/decorators"> >>> <excludes> >>> <pattern>/*ajax=true*</pattern> >>> <pattern>/*decorate=false*</pattern> >>> <pattern>/struts/dojo/*</pattern> <!-- OK to remove if you're >>> not using Struts --> >>> <pattern>/resources/*</pattern> >>> </excludes> >>> <decorator name="default" page="default.jsp"> >>> <pattern>/*</pattern> >>> </decorator> >>> </decorators> >>> i added the decorate=false part. urls with this parameter will not be >>> decorated. >>> >>> so an example would be nice right: >>> below an ajaxTest.jsp page which will be the caller. >>> than an ajaxReturn.jsp page which will be the returned data. >>> i expect you can make an AjaxAction with the methods String ajax(), >>> getPersons() etc..by your self. >>> than this is connected by struts like this: >>> -------------------------------------------------------- >>> <action name="ajax" class="ajaxTest"> >>> <result>/WEB-INF/pages/employee/ajaxTest.jsp</result> >>> <result >>> name="ajax">/WEB-INF/pages/employee/ajaxReturn.jsp</result> >>> </action> >>> >>> ------------------------------------------------------- >>> the ajaxTest.jsp: >>> <%@ taglib prefix="s" uri="/struts-tags"%> >>> <head> >>> <script type="text/javascript"> >>> dojo.event.topic.subscribe("/edit", function(data, type, >>> request) { >>> alert("type: "+type); >>> alert("data: "+data); >>> if(type="load"){ >>> document.getElementById("result").innerHTML=data; >>> } >>> >>> }); >>> </script> >>> </head> >>> >>> <!-- URL link to struts action--> >>> <s:url id="ajaxText" action="ajax" method="ajax" > >>> <s:param name="decorate" value="false" /> >>> </s:url> >>> >>> <!-- Div where content will be displayed --> >>> <s:div theme="ajax" id="weather" href="${ajaxText}"> >>> loading content... from the ajax action the ajax method is called. >>> than the ajaxReturn.jsp is rendered here. >>> </s:div> >>> >>> >>> <p>Persons</p> >>> <s:if test="persons.size > 0"> >>> <table> >>> <s:iterator value="persons"> >>> <tr id="row_<s:property value="id"/>"> >>> <td> >>> <s:property value="firstName" /> >>> </td> >>> <td> >>> <s:property value="lastName" /> >>> </td> >>> <td> >>> <!-- call the remove method on the ajax action no >>> return--> >>> <s:url id="removeUrl" action="ajax" method="remove"> >>> <s:param name="id" value="id" /> >>> <s:param name="decorate" value="false" /> >>> </s:url> >>> <s:a href="%{removeUrl}" theme="ajax" >Remove</s:a> >>> >>> <!-- call the edit method an the ajax action. the >>> result (ajaxResult.jps) >>> will be handed to the edit javascript mothed >>> attached to dojo (above) --> >>> <s:url id="editUrl" action="ajax" method="ajax"> >>> <s:param name="id" value="id" /> >>> <s:param name="decorate" value="false" /> >>> </s:url> >>> <s:a href="%{editUrl}" id="a_%{id}" theme="ajax" >>> notifyTopics="/edit">Edit</s:a> >>> </td> >>> <td> >>> ajax!remove.html?id=2 remove me no ajax >>> </td> >>> </tr> >>> </s:iterator> >>> </table> >>> </s:if> >>> >>> <hr> >>> <div id=result></div> >>> ------------------------------------------------------------------------------------------------------------------------------ >>> the ajaxResult.jsp: >>> <%@ taglib prefix="s" uri="/struts-tags"%> >>> Make some nice form here. Now show all persons. >>> <s:iterator value="persons"> >>> <table><tr><td><s:property value="firstName" /></td> >>> <td><s:property value="lastName" /></td> >>> </tr> >>> </table> >>> </s:iterator> >>> ------------------------------------------------------------------------------------------------------------------------ >>> ok here is my action to: >>> package nl.incipio.match.webapp.action; >>> >>> import java.util.List; >>> >>> import org.appfuse.model.User; >>> >>> import com.opensymphony.xwork2.Preparable; >>> >>> import nl.incipio.match.util.MyBaseAction; >>> >>> public class AjaxTestAction extends MyBaseAction implements Preparable { >>> private static final long serialVersionUID = 378605805550104346L; >>> >>> private List<User> persons; >>> >>> private Long id; >>> >>> @Override >>> public String execute() throws Exception { >>> log.debug("just getting the stuf"); >>> persons = (List<User>) getRequest().getAttribute("persons"); >>> if (persons == null) { >>> log.debug("just ones please"); >>> persons = userManager.getUsers(null); >>> getRequest().setAttribute("persons", persons); >>> } else { >>> log.debug("persons" + persons.size()); >>> } >>> return SUCCESS; >>> } >>> >>> public List<User> getPersons() { >>> return persons; >>> } >>> >>> public void setPersons(List<User> persons) { >>> this.persons = persons; >>> } >>> >>> public String remove() throws Exception { >>> log.debug("do some removing here when i feel like it id:" + id); >>> if (persons != null) { >>> log.debug("before persons" + persons.size()); >>> persons.remove((id.intValue() - 1)); >>> log.debug("after persons" + persons.size()); >>> } >>> return SUCCESS; >>> } >>> >>> public String save() throws Exception { >>> log.debug("do some saving here when i feel like it"); >>> return execute(); >>> } >>> >>> public String ajax() { >>> log.debug("ajax is doing something id:"+id); >>> return "ajax"; >>> } >>> >>> public String edit() throws Exception { >>> log.debug("do some editing here when i feel like it"); >>> return execute(); >>> } >>> >>> public Long getId() { >>> return id; >>> } >>> >>> public void setId(Long id) { >>> this.id = id; >>> } >>> >>> public void prepare() throws Exception { >>> log.debug("i'm getting prepared!!!"); >>> >>> } >>> } >>> ------------------------------------------------------------------ >>> spring config in applicationContext.xml: >>> <bean id="ajaxTest" >>> class="nl.incipio.match.webapp.action.AjaxTestAction"> >>> <property name="userManager" ref="userManager"/> >>> </bean> >>> >>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >>> For additional commands, e-mail: users-h...@appfuse.dev.java.net >>> >>> >> >> >> -- >> http://raibledesigns.com >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net >> For additional commands, e-mail: users-h...@appfuse.dev.java.net >> >> >> > > -- > View this message in context: > http://www.nabble.com/dojo-tutorial-extension-tp12654762s2369p22599937.html > Sent from the AppFuse - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net > For additional commands, e-mail: users-h...@appfuse.dev.java.net > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@appfuse.dev.java.net For additional commands, e-mail: users-h...@appfuse.dev.java.net