[S2] Ajax error
Hi, I've just started experimenting with Ajax capabilities in S2. For this I m getting the time from action class when ever user clicked the 'Get time' button. ... Current time from server .. It is getting time from server asynchronously, but the is displaying the whole page again inside it. What am I doing wrong? Can some one tell or direct me to some good example about ajax usage in S2, when to and how to use listenTopic/notifyTopics Regards, ManiKanta G ** DISCLAIMER ** Information contained and transmitted by this E-MAIL is proprietary to Sify Limited and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Company. If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited. If you have received this communication in error, please delete this mail & notify us immediately at [EMAIL PROTECTED]
Re: [S2] Ajax error
--- On Wed, 9/10/08, ManiKanta G wrote: > ... > > > > > > Current time from server > theme="ajax" id="timeDiv"> > > > > >notifyTopics="time"/> > > > .. > > It is getting time from server asynchronously, but the > is > displaying the whole page again inside it. > > What am I doing wrong? Hard to say, since you don't provide any information about the "Time" action used by your tag. I'd guess that its result is returning an entire page, rather than an HTML fragment, which is what you'd probably want. > Can some one tell or direct me to some good example about ajax > usage in S2, when to and how to use listenTopic/notifyTopics. You use listen topics when you want something (component, JavaScript, etc.) to pay attention to published events, and notify topics when you want to publish an event. Your example above could be reduced to (more or less; I have no way to test at the moment): Where #url is the URL of an action that returns the current date, probably the same as the form action. As for documentation: S2.1: http://struts.apache.org/2.x/docs/ajax-tags.html S2.0: http://struts.apache.org/2.0.11/docs/ajax-tags.html Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Ajax error
Thanks Dave. Yes, from action class I m returning entire jsp page. Action class: public class TimeServer extends ActionSupport { private Date date = null; public String execute() throws InterruptedException { System.out.println("Request received..."); date = new Date(); return SUCCESS; } public Date getDate() { return date; } } Config: /pages/listtime.jsp class="com.timeserver.struts2.action.TimeServer"> /pages/listtime.jsp initially I m requesting TimePage.action. >> I'd guess that its result is returning an entire page, rather than an HTML fragment, which is what you'd probably want. How can I return HTML fragment? you mean another jsp page which contains only that html fragment? If it is the case I may have to create many small jsps, which may in the order of 100s. Or you talking about some thing else? And is there any way to substitute the with . I've tried with this, but only submit is making request to action. Thanks for resource links. Regards, ManiKanta G Dave Newton wrote: --- On Wed, 9/10/08, ManiKanta G wrote: ... Current time from server notifyTopics="time"/> .. It is getting time from server asynchronously, but the is displaying the whole page again inside it. What am I doing wrong? Hard to say, since you don't provide any information about the "Time" action used by your tag. I'd guess that its result is returning an entire page, rather than an HTML fragment, which is what you'd probably want. Can some one tell or direct me to some good example about ajax usage in S2, when to and how to use listenTopic/notifyTopics. You use listen topics when you want something (component, JavaScript, etc.) to pay attention to published events, and notify topics when you want to publish an event. Your example above could be reduced to (more or less; I have no way to test at the moment): Where #url is the URL of an action that returns the current date, probably the same as the form action. As for documentation: S2.1: http://struts.apache.org/2.x/docs/ajax-tags.html S2.0: http://struts.apache.org/2.0.11/docs/ajax-tags.html Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ** DISCLAIMER ** Information contained and transmitted by this E-MAIL is proprietary to Sify Limited and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Company. If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited. If you have received this communication in error, please delete this mail & notify us immediately at [EMAIL PROTECTED]
Re: [S2] Ajax error
--- On Wed, 9/10/08, ManiKanta G wrote: > Yes, from action class I m returning entire jsp page. Well, that would explain why you're seeing an entire page in the div, then. > How can I return HTML fragment? you mean another jsp page > which contains only that html fragment? Yes, if you're loading the div with HTML. > If it is the case I may have to create many small jsps, > which may in the order of 100s. That's what Ajax does (loosely speaking): returns HTML fragments (or data as JSON, XML, etc.). That's the point of it--so you don't have to return entire pages and refresh the entire window. > And is there any way to substitute the with . > I've tried with this, but only submit is making request to action. Examples of using to both populate a div and to submit a form, inside or outside said form, are given in the documentation for both S2 versions. If you have specific questions it'll be easier to help. Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [S2] Ajax error
Thanks Dave. I'll Will do accordingly. Thanks, ManiKanta Dave Newton wrote: --- On Wed, 9/10/08, ManiKanta G wrote: Yes, from action class I m returning entire jsp page. Well, that would explain why you're seeing an entire page in the div, then. How can I return HTML fragment? you mean another jsp page which contains only that html fragment? Yes, if you're loading the div with HTML. If it is the case I may have to create many small jsps, which may in the order of 100s. That's what Ajax does (loosely speaking): returns HTML fragments (or data as JSON, XML, etc.). That's the point of it--so you don't have to return entire pages and refresh the entire window. And is there any way to substitute the with . I've tried with this, but only submit is making request to action. Examples of using to both populate a div and to submit a form, inside or outside said form, are given in the documentation for both S2 versions. If you have specific questions it'll be easier to help. Dave ** DISCLAIMER ** Information contained and transmitted by this E-MAIL is proprietary to Sify Limited and is intended for use only by the individual or entity to which it is addressed, and may contain information that is privileged, confidential or exempt from disclosure under applicable law. If this is a forwarded message, the content of this E-MAIL may not have been sent with the authority of the Company. If you are not the intended recipient, an agent of the intended recipient or a person responsible for delivering the information to the named recipient, you are notified that any use, distribution, transmission, printing, copying or dissemination of this information in any way or in any manner is strictly prohibited. If you have received this communication in error, please delete this mail & notify us immediately at [EMAIL PROTECTED]