Executing script in an ajax response requires parsing out the script
and eval'ing it separately (your browser protecting you from scripting
attacks). This can be done with scriptaculous but is disabled by
default. I can't see a way to override this in Tapestry without
duplicating code from tapestry.js.

Tapestry is also using
http://wiki.script.aculo.us/scriptaculous/show/Ajax.Request
instead of
http://wiki.script.aculo.us/scriptaculous/show/Ajax.Updater

which, at least as documented, is the recommended object for ajax
requests that returns rendered content... (I'm not sure why it's the
recommended object, that's just what the docs say...)

You'll probably have to write some of your own javascript to get this
to work at this time...

Josh

On Thu, Mar 13, 2008 at 4:23 AM, Andreas Pardeike <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have a login component that updates itself via a zone. Works
> great especially when you enter wrong values (server side verified).
>
> Now, if the form successfully logs in or out, I want to refresh
> the current page because it likely looks different because of the
> state change.
>
> I tried many things including a <script></script> inside the block
> but since its an ajax request, JS is not executed. Or is it and
> I am doing something wrong.
>
> Any insides appreciated,
> Andreas Pardeike
>
> --
>
> Here is my Login component:
>
> <t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd
> ">
>   <div class="kl-login-container">
>     <div style="border:1px solid red">
>       <t:zone t:id="loginzone" t:update="show">
>         <t:delegate to="formblock" />
>       </t:zone>
>     </div>
>   </div>
>   <t:block t:id="formblock">
>     <t:form t:id="loginform" class="kl-login-content"
> t:zone="loginzone">
>       <t:if test="loggedIn" negate="true">
>         <t:if test="isWrongLogin" negate="true">
>           <p class="kl-login-head">${message:titleok}</p>
>         </t:if>
>         <t:if test="isWrongLogin">
>           <p class="kl-login-head">${message:titlebad}</p>
>         </t:if>
>         <div class="kl-login-input">
>           <t:textfield class="email" t:id="email"
> validate="required,regexp" />
>           <t:submit class="button" value="message:login" />
>         </div>
>         <div class="kl-login-autologin">
>           <t:checkbox t:id="autologin" />
>           <span class="automessage">${message:automessage}</span>
>         </div>
>         <div style="clear:both" />
>       </t:if>
>       <t:if test="loggedIn">
>         <p class="kl-login-head">${message:loggedinas} $
> {customerDisplayName}</p>
>         <div class="kl-login-input">
>           <t:submit class="button" value="message:logout" />
>         </div>
>       </t:if>
>     </t:form>
>     <t:if test="refreshPage">
>       Redirecting..<br />
>       <script>
>         alert('redirect!');
>         document.location = document.location;
>       </script>
>     </t:if>
>   </t:block>
> </t:container>
>
>
> and it's source:
>
>
> package se.fsys.klubb.components.login;
>
> import org.apache.tapestry.Block;
> import org.apache.tapestry.annotations.ApplicationState;
> import org.apache.tapestry.annotations.OnEvent;
> import org.apache.tapestry.annotations.Property;
> import org.apache.tapestry.ioc.annotations.Inject;
>
> import se.fsys.klubb.access.AccessController;
> import se.fsys.klubb.aso.Session;
> import se.fsys.klubb.beans.Credentials;
>
> public class Login
> {
>   @Inject
>   private Block formblock;
>
>   @ApplicationState
>   private Session _session;
>   private boolean _sessionExists;
>
>   @Inject
>   private AccessController _access;
>
>   @Property
>   private String _email;
>
>   @Property
>   private boolean _autologin;
>
>   @SuppressWarnings("unused")
>   @Property
>   private boolean _isWrongLogin;
>
>   @SuppressWarnings("unused")
>   @Property
>   private boolean _refreshPage;
>
>   public Block getFormBlock()
>   {
>     return formblock;
>   }
>
>   @OnEvent(component = "loginform", value = "success")
>   public Block successFromLoginForm()
>   {
>     _isWrongLogin = false;
>     _refreshPage = false;
>
>     // log out
>     //
>     if(isLoggedIn())
>     {
>       _session.setCredentials(null, true);
>       _access.clearAutoCredentialsCookie();
>       _refreshPage = true;
>     }
>
>     // log in
>     //
>     Credentials credentials = new Credentials();
>     credentials.setCustomerID(_email);
>     if(_access.validateCredentials(credentials))
>     {
>       _session.setCredentials(credentials, false);
>       if(_autologin)
>         _access.writeAutoCredentialsToCookie(credentials);
>       _refreshPage = true;
>     }
>     else
>     {
>       if(_sessionExists)
>         _session.setCredentials(null, true);
>       _access.clearAutoCredentialsCookie();
>       _isWrongLogin = true;
>     }
>
>     return formblock;
>   }
>
>   public boolean isLoggedIn()
>   {
>     if(!_sessionExists)
>       return false;
>     return _session.getCredentialsValid();
>   }
>
>   public String getCustomerDisplayName()
>   {
>     return _session.getCredentials().getCustomerDisplayName();
>   }
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to