I'm replicating the state in which a new user will hit the site, they won't
have any of the cookies set by Tapestry.


Sven Homburg wrote:
> 
> why do you delete the cookies ?
> 
> 2008/5/8 lebenski <[EMAIL PROTECTED]>:
> 
>>
>> Hi guys,
>>
>> Ok i've got an urgent problem.  I'm using tapestry to develop a web app,
>> which I have to present tomorrow to some very important people!
>>
>> I've got a very frustrating problem.  I will try to explain it as clearly
>> as
>> possible.
>>
>> I'm using the t5components/OnEvent Mixin to call back to Tapestry
>> 'onChange'
>> of a textfield.
>>
>> TML:
>>
>>  <t:form t:id="registerBasicForm" t:class="gamesysForm"
>> zone="registerBasicZone">
>> ....
>>                            <t:label for="registerbasic_userName">
>>                                User Name:
>>                            </t:label>
>>                            <t:textfield t:id="registerbasic_userName"
>> t:value="userName"
>> event="change" onfocus="showFieldHint('4-16
>> characters');showFieldError('registerbasic_userName');"/>
>>
>> ....
>> </t:form>
>>
>> Page Class:
>>
>> @Component(id = "registerbasic_userName", parameters = { "event=change",
>>                       
>> "onCompleteCallback=checkForServerValidationErrors"
>> })
>>        @Mixins("t5components/OnEvent")
>>        private TextField userNameField;
>>
>> ...
>>
>>        @OnEvent(component = "registerbasic_userName", value = "change")
>>        public JSONObject onChangeFromUserName(String value) {
>>                System.out.println("onChangeFromUserName");
>>                JSONObject json = new JSONObject();
>>                Boolean userNameExists = false;
>>
>>                Pattern p =
>> Pattern.compile(messages.get("alphanumeric-regex"));
>>                Matcher m = p.matcher(value);
>>                boolean validUserName = m.find();
>>
>>                if (validUserName) {
>>                        try {
>>                                userNameExists =
>> hydraService.userNameExists(value);
>>                        } catch (ServiceFaultException x) {
>>                                logger.error("----fault : " +
>> x.getFault().getMessage());
>>                        } catch (ServiceProblemException x) {
>>                                logger.error("----problem:" + x);
>>                        }
>>
>>                        if (userNameExists) {
>>                                json.put("error", "true");
>>                                json
>>                                                .append("message",
>> "Username " + value
>>                                                                + " is
>> taken");
>>                        } else {
>>                                json.put("error", "false");
>>                                json.append("message", "");
>>                        }
>>
>>                } else {
>>                        json.put("error", "true");
>>                        json.append("message", "Field contains invalid
>> characters");
>>                }
>>
>>                json.append("submitid", "submitRegisterBasic");
>>                json.append("field", "registerbasic_userName");
>>                System.out.println(json.get("error") + " " +
>> json.get("field") + " "
>>                                + json.get("message"));
>>
>>                return json;
>>        }
>>
>> Javascript:
>>
>>        function checkForServerValidationErrors(response){
>>
>>                var json = response.evalJSON();
>>                var elementId = json.field.toString();
>>
>>                //This MUST be done first
>>                performTypeValidation(elementId);
>>
>>            if (json!=null && json.error == 'true' &&
>> formErrors[elementId]==null)
>> {
>>                        addFormValidationError(elementId,json.message);
>>            }
>>
>>
>>  processValidationErrors(elementId,json.submitid.toString());
>>        }
>>
>> So, what happens is, when the user types a value into 'userName', and
>> exits
>> the field (onChange seems to act like onBlur), it calls back to Tapestry
>> which executes the onChangeFromUserName(String value) method to check if
>> the
>> username exists in the database.  This then calls back to the javascript
>> function (defined in the Component annotation) with a JSON object.  The
>> javascript is used for client side validation/presentational stuff.
>>
>> This all works fine under normal conditions.  HOWEVER, when I clear my
>> cookies and do the same action (type a value into 'username' and tab
>> out),
>> i
>> get a javascript error 'json.field has no properties'.  The server side
>> method (onChangeFromUserName) isn't getting called (I can tell because it
>> doesnt hit System.out.println("onChangeFromUserName");), BUT it is
>> calling
>> back to the javascript function.  Rightly so, the javascript is
>> complaining
>> because the JSON object hasn't been passed in.
>>
>> 2 cookies are getting set, JSESSIONID and UTRACK, and they do get sent
>> both
>> on the initial request (right after i've cleared my cookies) and the
>> request
>> after.  But for some reason, i'm not hitting the server method on the
>> initial request.
>>
>> I have used tamper data to analyse both requests and they appear to be
>> identical.  Both cookies are getting sent, all the headers are identical.
>>
>> I am at a real loss and starting to panic about this.  I'm starting to
>> think
>> that Tapestry needs a request to properly set up the session, before you
>> can
>> actually call back to it, but this is only a hunch.
>>
>> I really need to get this sorted, if you have any ideas then please help!
>> --
>> View this message in context:
>> http://www.nabble.com/T5%3A-Urgent-Problem.-After-clearing-cookies-communication-between-client-and-tapestry-breaks-on-first-request-tp17123771p17123771.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
> 
> 
> -- 
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
> 
> 
> -----
> best regards
> Sven
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-Urgent-Problem.-After-clearing-cookies-communication-between-client-and-tapestry-breaks-on-first-request-tp17123771p17123963.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to