Guys,

I am whipping up a simple Login page... no *.page files just annotations. The page displays and the validators are nice.

If someone could bail me out here I would be greatful. The Login.html quits on trying to render the OGNL for emailAddress.

OGNL is having trouble getting to this object (Person object persisted and created during onrender)

I am kinda blue in the face...

Do you see anything in my code preventing the html from retrieving this property?

What am I missing? Thanks so much.

Here is the exception...
   org.apache.tapestry.BindingException
Unable to read OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED]: $BasePage_4.emailAddress
   binding:     ExpressionBinding[Login emailAddress]

Thanks in advance

-------- Login.html code follows ----
<html jwcid="@Shell" title="message:page.title">
<body jwcid="@Body">

        <h1><span jwcid="@Insert" value="message:page.title"/></h1>

        <form jwcid="[EMAIL PROTECTED]"
       success="listener:onFormSubmit"
       cancel="listener:onFormCancel"
       clientValidationEnabled="ognl:true" >
                <table border="0">
                <tr>
           <td>
<span jwcid="@Insert" value="message:label.emailAddress">EmailAddress:</span>
           </td>

<td><input jwcid="[EMAIL PROTECTED]" value="ognl:emailAddress" validators="validators:required" displayName="message:label.emailAddress" size="40" /></td>
       </tr>
                <tr>
           <td>
                                <span jwcid="@Insert" 
value="message:label.password">Password:</span>
           </td>
           <td><input jwcid="[EMAIL PROTECTED]" value="password"
validators="validators:required" displayName="message:label.password" size="40"/></td>
       </tr>

       <tr>
           <td/>
           <td>
<input type="submit" jwcid="[EMAIL PROTECTED]" label="message:label.login" /> <input type="submit" jwcid="[EMAIL PROTECTED]" label="message:label.cancel" onclick="javascript:this.form.events.cancel();" />
           </td>
       </tr>
                <tr>
        <td/>
           <td>
                <span jwcid="@Insert" value="message:label.rememberMe"/>
                <input jwcid="[EMAIL PROTECTED]" value="rememberMe"/>
        </td>
       </tr>

                </table>
        </form>
        <p><a href="#" jwcid="@PageLink" page="Home">Home</a></p>
</body>
</html>

-------- Login.java -----

package proto;

import java.rmi.RemoteException;

import javax.security.auth.login.LoginException;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.annotations.Bean;
import org.apache.tapestry.annotations.Component;
import org.apache.tapestry.annotations.InjectComponent;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.annotations.InjectState;
import org.apache.tapestry.annotations.InjectPage;

import org.apache.tapestry.annotations.Meta;
import org.apache.tapestry.annotations.Persist;
import org.apache.tapestry.callback.ICallback;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.form.IFormComponent;
import org.apache.tapestry.form.TextField;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.services.CookieSource;
import org.apache.tapestry.valid.*;
import org.apache.tapestry.valid.IValidationDelegate;
import org.apache.tapestry.valid.ValidationDelegate;

@Meta("anonymous-access=true")
public abstract class Login extends BasePage implements PageBeginRenderListener {

   @Persist
   public abstract Person getPerson();
   public abstract void setPerson(Person p);

        @Bean
        public abstract ValidationDelegate getDelegate();

        @InjectPage("Home")
        public abstract Home getHomePage();

        @InjectPage("Login")
        public abstract Login getLoginPage();

        public Home onFormSubmit() {
                Person person = Persons.getKnownPersons().getPerson(
                                getEmailAddress().toString(), 
getPassword().toString());
                return getHomePage();
        }

        @Component(type = "TextField", id = "emailAddress", bindings = {
                        "value = ognl:person.emailAddress",
                        "displayName = message:label.emailAddress", "validators = 
required" })
        public abstract TextField getEmailAddressComponent();
        public abstract String getEmailAddress();
        public abstract void setEmailAddress(String emailAddress);

        @Component(type = "TextField", id = "password", bindings = {
                        "value = ognl:person.password", "displayName = 
message:label.password",
                        "validators = required,minLength=6,maxLength=16" })
        public abstract TextField getPasswordComponent();
        public abstract String getPassword();
        public abstract void setPassword(String password);

        @Component(type = "Checkbox", id = "rememberMe", bindings = {
                        "value = ognl:rememberMe", "displayName = 
message:label.rememberMe" })
        public abstract boolean rememberMe();


        public Home login(IRequestCycle cycle) {
                String emailAddress = getEmailAddress().toString();
                String password = getPassword().toString();

                StringBuffer sb = new StringBuffer(emailAddress);
                String validPassword = sb.reverse().toString();
                if (password.equals(validPassword))
                        cycle.activate("listener");

                getCookieSource().writeCookieValue(COOKIE_NAME,
                                getEmailAddress().toString(), COOKIE_MAX_AGE);

                cycle.forgetPage(getPageName());
                return getHomePage();
        }

        private static final String COOKIE_NAME = "Login.emailAddress";

        private static final int COOKIE_MAX_AGE = 60 * 60 * 24 * 7;

        @InjectObject("infrastructure:cookieSource")
        public abstract CookieSource getCookieSource();

        public void pageBeginRender(PageEvent event) {
                if (getPerson() == null) {
                        System.out.println("creating new person");
                        Person p = new Person();
                        p.setEmailAddress("[EMAIL PROTECTED]");
                        p.setPassword("[EMAIL PROTECTED]");
                        setPerson(p);
                }
                if ("".equals(getPerson().getEmailAddress()))
                        getCookieSource().readCookieValue(COOKIE_NAME);
        }

        public String onFormCancel() {
                // setEmailAddress("");
                return "Home";
        }
}

--------- here is the whole exception ------
[ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED]: $BasePage_4.emailAddress
org.apache.tapestry.BindingException
Unable to read OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED]: $BasePage_4.emailAddress
binding:        ExpressionBinding[Login emailAddress]
location:       context:/Login.html, line 16
11      <tr>
12      <td>
13 <span jwcid="@Insert" value="message:label.emailAddress">EmailAddress:</span>
14      </td>
15
16      <td><input jwcid="[EMAIL PROTECTED]" value="ognl:emailAddress"
17 validators="validators:required" displayName="message:label.emailAddress" size="40" /></td>
18      </tr>
19      <tr>
20      <td>
21      <span jwcid="@Insert" value="message:label.password">Password:</span>

[ +/- ] Exception: Unable to read OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED]: $BasePage_4.emailAddress
org.apache.hivemind.ApplicationRuntimeException
Unable to read OGNL expression '<parsed OGNL expression>' of [EMAIL PROTECTED]: $BasePage_4.emailAddress
component:      [EMAIL PROTECTED]
location:       context:/WEB-INF/Login.page, line 5, column 21
1       <?xml version="1.0" encoding="UTF-8"?>
2       <!DOCTYPE page-specification PUBLIC
3       "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
4       "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd";>
5       <page-specification>
6
7       </page-specification>

[ +/- ] Exception: $BasePage_4.emailAddress



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

Reply via email to