--- On Wed, 9/10/08, ManiKanta G wrote:
>     ...
>     <head>
>         <s:head theme="ajax"/>
>     </head>
> 
>     <body>
>         Current time from server
>         <s:div cssStyle="border: 1px solid red;"
>                theme="ajax" id="timeDiv">
>             <s:date name="date"/>
>         </s:div>
>         <br>
>         <s:form action="Time">
>             <s:submit theme="ajax" targets="timeDiv" 
>                       notifyTopics="time"/>
>         </s:form>
>     </body>
>     ......
> 
> It is getting time from server asynchronously, but the
> <s:div ...> 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 <s:form...> 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):

<s:div id="timeDiv" href="%{#url}"></s:div>

<s:form action="Time">
  <s:submit theme="ajax" targets="timeDiv"/>
</s:form>

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]

Reply via email to