Re: Ajax form not holding onto field values after validation error.
IMHO, I think it's helpful to indicate when and why you're instantiating UserProfile, rather than just conditioning by "is null". void onPrepareForRender() throws Exception { // If fresh start, make sure there's a UserProfile object available. if (form.isValid()) { person = new UserProfile(); } } void onPrepareForSubmit() throws Exception { // Instantiate a UserProfile for the form data to overlay. person = new UserProfile(); } Just my two cents worth. On 15 Oct 2014, at 2:39 am, George Christman wrote: > Yup, that's exactly what was happening. > > On Tue, Oct 14, 2014 at 11:35 AM, Lance Java > wrote: > >> This makes sense. For validation errors, tapestry does NOT >> redirect-after-post so the POST request is the same as the render request. >> I can only assume that onPrepare() is called twice in the same request in >> the case of validation errors so your null check stops the POST values from >> being overridden. >> > > > > -- > George Christman > www.CarDaddy.com > P.O. Box 735 > Johnstown, New York
Re: How do I render zone from component A in component B
I'm nodding enthusiastically as I read Kalle's comments. He's right - the differences between being in an authenticated state and non-authenticated state are so significant and it simplifies matters if a page can assume it is dealing with just one state or the other. I should have mentioned this special case earlier. As an aside, another special case exists: where the components are deep in different parts of the page's tree of components and "acting quite independently". In this case a "pub-sub" mechanism could be better than "bubble up and call down". If the subscribing component has enough state info available to be able to generate a zone, then server-side pub-sub might suffice... https://github.com/anjlab/anjlab-tapestry-commons/blob/master/anjlab-tapestry-commons/src/main/java/com/anjlab/tapestry5/services/events/Publisher.java ...otherwise you'd need client-side pub-sub. Today you'd have to write that yourself. It's discussed here... https://issues.apache.org/jira/browse/TAP5-2383 Geoff On 15 Oct 2014, at 5:56 am, Kalle Korhonen wrote: > On Tue, Oct 14, 2014 at 11:11 AM, George Christman > wrote: > >> Commented inline >> On Tue, Oct 14, 2014 at 12:15 PM, Kalle Korhonen < >> kalle.o.korho...@gmail.com >>> wrote: >>> On Tue, Oct 14, 2014 at 8:18 AM, George Christman < >> gchrist...@cardaddy.com >>> wrote: >>> My original response still stands and I know what you are trying to >>> accomplish but it gets tricky trying to get it all done asynchronously, >> and >>> in general I advice to just handle sign-in/sign-up via a full page >> refresh. >> I really do like the smooth user experience async can provide to the end >> user, but I guess it might just be easier to do a full page >> refresh in most cases. There is one use case where the user fills in a form >> prior to login and I would like to keep the login async if possible. It >> helps prevent me from >> having to store the object into memory while they are being authenticated. >> > > Yes, I perfectly understand that desire. Just saying because I've been down > on that path before and ended up shooting myself in the foot and in > retrospect, it would have been much easier in my case to accept the full > page refresh and spend the development capacity on increasingly complex > implementation for async authentication on something else. > > >>> >>> Just as an anecdotal evidence and totally IMHO, stackoverflow.com has >> one >>> of the best designs out there for sign-in/sign-up flows and they are >> doing >>> it as a separate page as well. >>> >> I plan to borrow a few ideas form them, they do a nice job. I just hate >> having to leave a page to come back to it. Just seems cumbersome. >> >> Does the security framework have the ability to redirect the user back to >> the original page they were on prior to clicking the login link rather than >> say account home? >> Example of desired behavior, I'm looking at my listing, but decide I want >> to edit the listing. I click the nav sign in link and it redirects me to >> the login page. Once I'm logged in, I'd like to be redirected back to the >> listing page rather than the account landing page. This was one of the >> reasons I liked the async approach. >> > > Yes, Tynamo's tapestry-security does - within a reason and the support for > it was enhanced in the latest version. For example, even if your edit link > was async, the security framework would automatically store a page render > link for the listing page. > > Kalle
Re: How do I render zone from component A in component B
On Tue, Oct 14, 2014 at 11:11 AM, George Christman wrote: > Commented inline > On Tue, Oct 14, 2014 at 12:15 PM, Kalle Korhonen < > kalle.o.korho...@gmail.com > > wrote: > > On Tue, Oct 14, 2014 at 8:18 AM, George Christman < > gchrist...@cardaddy.com > > wrote: > > My original response still stands and I know what you are trying to > > accomplish but it gets tricky trying to get it all done asynchronously, > and > > in general I advice to just handle sign-in/sign-up via a full page > refresh. > I really do like the smooth user experience async can provide to the end > user, but I guess it might just be easier to do a full page > refresh in most cases. There is one use case where the user fills in a form > prior to login and I would like to keep the login async if possible. It > helps prevent me from > having to store the object into memory while they are being authenticated. > Yes, I perfectly understand that desire. Just saying because I've been down on that path before and ended up shooting myself in the foot and in retrospect, it would have been much easier in my case to accept the full page refresh and spend the development capacity on increasingly complex implementation for async authentication on something else. > > > > Just as an anecdotal evidence and totally IMHO, stackoverflow.com has > one > > of the best designs out there for sign-in/sign-up flows and they are > doing > > it as a separate page as well. > > > I plan to borrow a few ideas form them, they do a nice job. I just hate > having to leave a page to come back to it. Just seems cumbersome. > > Does the security framework have the ability to redirect the user back to > the original page they were on prior to clicking the login link rather than > say account home? > Example of desired behavior, I'm looking at my listing, but decide I want > to edit the listing. I click the nav sign in link and it redirects me to > the login page. Once I'm logged in, I'd like to be redirected back to the > listing page rather than the account landing page. This was one of the > reasons I liked the async approach. > Yes, Tynamo's tapestry-security does - within a reason and the support for it was enhanced in the latest version. For example, even if your edit link was async, the security framework would automatically store a page render link for the listing page. Kalle
Re: How do I render zone from component A in component B
Commented inline On Tue, Oct 14, 2014 at 12:15 PM, Kalle Korhonen wrote: > On Tue, Oct 14, 2014 at 8:18 AM, George Christman > > wrote: > > > Geoff, I always try to follow you suggested pattern, but unfortunately I > > don't think it's always possible. I'd like to present a use case scenario > > and perhaps maybe you guys can break me out of my current design rut. > > *Use case 1* > > *Use case 2* > > I guess I'm just not sure how you can accomplish both use cases without > > running into an area where a component would not need to command it's > > container. > > I'm very interested in hearing your thoughts. I'm not opposed to changing > > my design to make everything work properly. > > > > My original response still stands and I know what you are trying to > accomplish but it gets tricky trying to get it all done asynchronously, and > in general I advice to just handle sign-in/sign-up via a full page refresh. > I really do like the smooth user experience async can provide to the end user, but I guess it might just be easier to do a full page refresh in most cases. There is one use case where the user fills in a form prior to login and I would like to keep the login async if possible. It helps prevent me from having to store the object into memory while they are being authenticated. There are multiple reasons for it: > - you are likely going to support full login page anyway, so the clever XHR > flow is not required > - the screen real estate get crowded once you add sign-up to the same flow > - if you add Oauth, it's best practice to do full page refreshes > - available security frameworks have better support for full page refreshes > - design for mobile - modal dialogs often have fixed sizes, makes sure all > your users see the necessary stuff without scrolling (especially sideways) > Mobile is always a top priority. I always create fluid designs, so fixed widths are never an issue and deff no sideways scroll :-p. - if you allow plain http for your site, async flow won't work when you > switch to https for authenticated users > Facebook requires the entire site to run in https while using canvas and I'm now finding google is encouraging site owners to switch to full https in exchange for a little bit better page rank. That being said I'll be going full https by the first of the year thus eliminating this issue. > > Just as an anecdotal evidence and totally IMHO, stackoverflow.com has one > of the best designs out there for sign-in/sign-up flows and they are doing > it as a separate page as well. > I plan to borrow a few ideas form them, they do a nice job. I just hate having to leave a page to come back to it. Just seems cumbersome. Does the security framework have the ability to redirect the user back to the original page they were on prior to clicking the login link rather than say account home? Example of desired behavior, I'm looking at my listing, but decide I want to edit the listing. I click the nav sign in link and it redirects me to the login page. Once I'm logged in, I'd like to be redirected back to the listing page rather than the account landing page. This was one of the reasons I liked the async approach. > Kalle > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York
Re: How do I render zone from component A in component B
I think you might be having the same issue I had a while ago [1] Both the layout and the component are defined by the page. It's a bit counter intuitive but the layout is not the component's parent so events will not bubble up to it. The page is the parent to both. [1] http://apache-tapestry-mailing-list-archives.1045711.n5.nabble.com/Event-Bubbling-not-working-td5722372.html
Re: How do I render zone from component A in component B
On Tue, Oct 14, 2014 at 8:18 AM, George Christman wrote: > Geoff, I always try to follow you suggested pattern, but unfortunately I > don't think it's always possible. I'd like to present a use case scenario > and perhaps maybe you guys can break me out of my current design rut. > *Use case 1* > *Use case 2* > I guess I'm just not sure how you can accomplish both use cases without > running into an area where a component would not need to command it's > container. > I'm very interested in hearing your thoughts. I'm not opposed to changing > my design to make everything work properly. > My original response still stands and I know what you are trying to accomplish but it gets tricky trying to get it all done asynchronously, and in general I advice to just handle sign-in/sign-up via a full page refresh. There are multiple reasons for it: - you are likely going to support full login page anyway, so the clever XHR flow is not required - the screen real estate get crowded once you add sign-up to the same flow - if you add Oauth, it's best practice to do full page refreshes - available security frameworks have better support for full page refreshes - design for mobile - modal dialogs often have fixed sizes, makes sure all your users see the necessary stuff without scrolling (especially sideways) - if you allow plain http for your site, async flow won't work when you switch to https for authenticated users Just as an anecdotal evidence and totally IMHO, stackoverflow.com has one of the best designs out there for sign-in/sign-up flows and they are doing it as a separate page as well. Kalle
Re: Custom validation js not firing in 5.4.
Does anybody using 5.4 understand this issue? I'm still unable to get the clientside validation js working. On Fri, Oct 10, 2014 at 1:59 PM, George Christman wrote: > I found one mistake where I wasn't calling the js directly from render, > but that still doesn't seem to resolve the issue. > > @Override > public void render(Field field, Integer constraintValue, > MessageFormatter formatter, MarkupWriter writer, > FormSupport formSupport) { > > if (formSupport.isClientValidationEnabled()) { > javaScriptSupport.require("custom-validation"); > writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true, > "data-validate-quarter-hour", > constraintValue.toString(), > "data-quarter-hour-message", buildMessage(formatter, > field, constraintValue)); > } > } > > (function() { > define(["underscore", "./dom", "./events", "./utils", "./messages", > "./fields"], function(_, dom, events) { > > dom.onDocument(events.field.validate, > "[data-validate-quarter-hour]", function(event, memo) { > alert('here'); > var max; > max = parseInt(this.attr("data-validate-quarter-hour")); > if (memo.translated % max === 0) { > memo.error = (this.attr("data-quarter-hour-message")); > return false; > } > }); > }); > > }).call(this); > > On Fri, Oct 10, 2014 at 1:35 PM, George Christman > wrote: > >> Hi guys, I have some custom js to handle some clientside validation in >> 5.4. I can't seem to get it to fire, could someone tell me what I'm doing >> wrong? >> >> custom-validation.js >> >> (function() { >> define(["underscore", "./dom", "./events", "./utils", "./messages", >> "./fields"], function(_, dom, events) { >> >> dom.onDocument(events.field.validate, >> "[data-validate-quarter-hour]", function(event, memo) { >> var max; >> max = parseInt(this.attr("data-validate-quarter-hour")); >> if (memo.translated % max === 0) { >> memo.error = (this.attr("data-quarter-hour-message")); >> return false; >> } >> }); >> }); >> >> }).call(this); >> >> >> @Import( module = {"custom-validation"}) >> >> >> @Override >> public void render(Field field, Integer constraintValue, >> MessageFormatter formatter, MarkupWriter writer, >> FormSupport formSupport) { >> System.out.println("is validation enabled " + >> formSupport.isClientValidationEnabled()); >> if (formSupport.isClientValidationEnabled()) { >> javaScriptSupport.require("t5/core/validation"); >> writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true, >> "data-validate-quarter-hour", >> constraintValue.toString(), >> "data-quarter-hour-message", buildMessage(formatter, >> field, constraintValue)); >> } >> } >> >> -- >> George Christman >> www.CarDaddy.com >> P.O. Box 735 >> Johnstown, New York >> >> > > > -- > George Christman > www.CarDaddy.com > P.O. Box 735 > Johnstown, New York > > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York
Re: Ajax form not holding onto field values after validation error.
Yup, that's exactly what was happening. On Tue, Oct 14, 2014 at 11:35 AM, Lance Java wrote: > This makes sense. For validation errors, tapestry does NOT > redirect-after-post so the POST request is the same as the render request. > I can only assume that onPrepare() is called twice in the same request in > the case of validation errors so your null check stops the POST values from > being overridden. > -- George Christman www.CarDaddy.com P.O. Box 735 Johnstown, New York
Re: Ajax form not holding onto field values after validation error.
This makes sense. For validation errors, tapestry does NOT redirect-after-post so the POST request is the same as the render request. I can only assume that onPrepare() is called twice in the same request in the case of validation errors so your null check stops the POST values from being overridden.
Re: How do I render zone from component A in component B
Geoff, I always try to follow you suggested pattern, but unfortunately I don't think it's always possible. I'd like to present a use case scenario and perhaps maybe you guys can break me out of my current design rut. *Use case 1* 1. My navigation bar is contained within my layout component which is available to all pages. The navigation bar contains an ajax link called login. When the user clicks the login link, it triggers an event in the layout.java called onShowLoginRegister. Layout.java public void onShowLoginRegister() { function = Function.LOGIN; if (request.isXHR()) { ajaxResponseRenderer.addRender(loginRegisterModalZone); } } 2. Also contained within layout is a component called LoginRegister which is nested within a modal dialog box surrounded by a zone which is triggered by the onShowLoginRegister response. 3. LoginRegister contains all the authentication code enabling users to log in inline despite what page they may be on. 4. When the user has been successfully authenticated, I then trigger another event in the layout to close the LoginRegister modal dialog as well as update the the user name in the navbar via a zone. LoginRegister.java Object onSuccessFromLoginForm() { // We want to tell our containing page explicitly what person we've updated, so we trigger a new event with a // parameter. It will bubble up because we don't have a handler method for it. componentResources.triggerEvent(LOGIN, null, null); // We don't want the original event to bubble up, so we return true to // say we've handled it. return true; } Layout.java void onLoginFromLoginRegister() { modalDialog.hide(); if (request.isXHR()) { ajaxResponseRenderer.addRender(loginRegisterModalZone).addRender(loginNavZone); } } So far everything works perfectly. Now comes the tricky part, updating page content. Now lets say I'm on a page that has actions or other content hidden to a non authenticated user. When I log in through my loginregister modal dialog, not only do I need to update the username contained within the layout navbar component, I also need to update a zone contained within the page to show actions now available to the authenticated user. Now I know you say everything should be controlled through the page, but in this scenario the event is being fired from the navbar contained within the layout component. MyPage.tml //actionZone should be triggered when the user has been successfully authenticated by loginregister. Ideally it should be updated with ajaxResponseRenderer within onLoginFromLoginRegister() //some actions that need to be displayed to authenticated users.
Re: Why do I have to explicitly render a zone if it's ID is specified in the ajax-enabled Select component ?
I used to have a dummy zone in my layout component so I can use it's ID to enable ajax for Select components if they aren't inside a zone and I can't use "^" !! > A good deal of the components already supports async parameter for exactly > > this. Chris, so not *all* components does ? Should I open a jira ticket for the select component or is there already one ? Is it planned ? It doesn't look like the Select component supports it but I found a TASK showing that EventLink, ActionLink and From components support this parameter now https://github.com/apache/tapestry-5/blob/master/tapestry-core/src/main/java/org/apache/tapestry5/corelib/base/AbstractComponentEventLink.java *-* *Muhammad Gelbana* http://www.linkedin.com/in/mgelbana On Tue, Oct 14, 2014 at 8:43 AM, Geoff Callender < geoff.callender.jumpst...@gmail.com> wrote: > Since 5.4! I'd completely missed that. Thanks. > > On 14 Oct 2014, at 5:39 pm, Chris Poulsen wrote: > > > Hi, > > > > On Tue, Oct 14, 2014 at 7:27 AM, Geoff Callender < > > geoff.callender.jumpst...@gmail.com> wrote: > > > >> > >> Perhaps it's time for Tapestry to replace the zone parameter with > >> ajax="true" or xhr="true"? > >> > >> Geoff > >> > > > > A good deal of the components already supports async parameter for > exactly > > this. > > > > -- > > Chris > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: Hibernate multiple databases
Hi Nathan, I've written a module which has support for multiple databases through Hibernate. It's roughly based on Taha's implementation. Besides that it contains a lot more usefull components ;) See: https://github.com/intercommit/Weaves Regards, Antal OriginalMessage >From: "Nathan Quirynen" >To: "Tapestry users" >Sent: Mon, Oct 13, 2014, 14:33 >Subject: Hibernate multiple databases > >Hi, > >For our current project we have the need to be able to connect to >multiple databases using Hibernate. >I have seen the blog post of Taha >(http://tawus.wordpress.com/2012/03/03/tapestry-hibernate-multiple-databases/) >and was wondering if there exists a library based on this or similar >that I can use as is? Else I will have to investigate in creating one >myself. > >Greetings Nathan > >- >To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >For additional commands, e-mail: users-h...@tapestry.apache.org > > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org