Re: outputting expression logic
> I don't think it's ever a good idea to output partial HTML in your page like this. I'll throw one more implementation into the ring. ${var:galleryEntry} http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";> /** * Gallery.java */ import org.apache.tapestry5.annotations.Parameter; import org.apache.tapestry5.annotations.Property; import java.util.Iterator; import java.util.NoSuchElementException; public class Gallery { @Parameter(required = true) private Iterable source; @Parameter(required = true) @Property private Object entry; @Parameter(required = true) private int entriesPerRow; @Parameter private int maxRows; @Property private WrappedIterable rows; @Property private LimitedIterable columns; void setupRender() { rows = new WrappedIterable(source); } public boolean getNeedsPadding() { return !rows.iterator.hasNext() && columns.count < entriesPerRow; } public int getPadding() { return entriesPerRow - columns.count; } public class WrappedIterable implements Iterable { private Iterator iterator; int rows = 0; private WrappedIterable(Iterable iterable) { iterator = iterable.iterator(); } public Iterator iterator() { return new Iterator() { public boolean hasNext() { return (maxRows <= 0 || rows < maxRows) && iterator.hasNext(); } public LimitedIterable next() { if (hasNext()) { ++rows; return new LimitedIterable(iterator, entriesPerRow); } throw new NoSuchElementException(); } public void remove() { throw new UnsupportedOperationException(); } }; } } public class LimitedIterable implements Iterable { int count = 0; private final Iterator iterator; private int limit; private LimitedIterable(Iterator iterator, int limit) { this.iterator = iterator; this.limit = limit; } public Iterator iterator() { return new Iterator() { public boolean hasNext() { return count < limit && iterator.hasNext(); } public Object next() { if (hasNext()) { ++count; return iterator.next(); } throw new NoSuchElementException(); } public void remove() { throw new UnsupportedOperationException(); } }; } } } Josh On Sat, Sep 17, 2011 at 6:40 PM, Ken in Nashua wrote: > > Rob, > > Thanks for the constructive criticism. > > I will give this a whirl... like what I see... > > I am all for good form... and one of the nice things I am excited about T5 is > that it promotes a ton of loose options for achieving good form. > > Appreciate the help and will let you know how I make out. > > - cheers > > KEN > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: dereferencing
By attributes I mean T5 component parameters, like "source" and "value" of the loop component. Whenever you're writing your .tml and want to pass a value to another component, use a bind:ing, don't use an ${expression}. ${expression}s are really just for outputing text into the HTML. Steve. -- Steve Eynon --- "If at first you don't succeed, so much for skydiving!" On 18 September 2011 05:25, Ken in Nashua wrote: > > Hey Steve, > > Awesome reply... > > Can you elaborate on your definition of > > ="attributes" > > Not sure what your calling that... syntactic, semantic or actual code... > > sorry if I am too conceptual... > > I am very excited about tap5 though... and shaking it out. > > - cheers > Ken >
RE: outputting expression logic
Thanks Rob... code ran as-is... auto-paging layout looks sweet I hope to finish this guy up and publish for public consumption by mid week or sooner... I just need to QA the action auto-paging links. Thanks... appreciate the help TML JAVA public boolean isHasColumnsAndItems() { return Math.min(tableColumns, itemsPerPage) > 0; } public boolean isAtRowEnd() { return ((index - cursor) % Math.min(tableColumns, itemsPerPage)) == 0; } public String getTrTags() { return ""; }
RE: outputting expression logic
Rob, Thanks for the constructive criticism. I will give this a whirl... like what I see... I am all for good form... and one of the nice things I am excited about T5 is that it promotes a ton of loose options for achieving good form. Appreciate the help and will let you know how I make out. - cheers KEN
Re: outputting expression logic
I've been developing with Tapestry since version 3. I finally reached the conclusion that templates like below are evil. :) The main reason for them in T4 was template reloading, so you had fast turnaround time when developing. In T5, you get page & component class reloading, as well, so the primary driver behind putting any logic in the template is gone. Here are a few reasons why I find templates like below evil: 1) It makes pages more brittle and prone to break during refactoring 2) It makes it easier for a designer (or anyone, really) to hose the page/component (there's just a lot more stuff in there to break by accident) 3) It's considerably more difficult to understand/read (and therefore to maintain!) Here's a T5 version of your snippet below: .tml: .java: @Property private int index; @Property private Object currentObject; public String getTrTags() { return ""; } public boolean isOkToRenderItem() { /* whatever your original method was */ } public boolean isHasColumnsAndItems() { return Math.min(tableColumns, itemsPerPage) > 0;/*since you're referencing these as properties in your page, I'm assuming they are available as properties in your page already*/ } public boolean isAtRowEnd() { return ((index - cursor) % Math.min(tableColumns, itemsPerPage)) == 0;/* again assuming that cursor, tableColumns, and itemsPerPage are available as properties in your page/component class... possibly as parameter values?)*/ } Maybe it's just me... I like the T5 version a lot better. :) Robert On Sep 17, 2011, at 9/174:19 PM , Ken in Nashua wrote: > > > > > > > > > > Thanks Thiago... I didn't think it unreasonable to have fundamental ops to > take code like this... > > value="ognl:currentObject" index="ognl:index"> > > > > > raw="true"/> > > > > and have tap5 honor the same semantic (arithmetic and method calls) in some > way or another... > > I refuse to violate the page code and self contained components is pure > tapestry anyway. > > It seems I need chenelle... > > Can you recommend a chenelle version for tap 5.3.0 ? > > Thank You > > > - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: outputting expression logic
Wow, I wouldn't want to have to maintain an app full of tml files like that. I think you're not realizing yet how much more maintainable a good clean T5-style template really is. Java is so much more expressive for logic anyway. Bob Harner On Sep 17, 2011 5:20 PM, "Ken in Nashua" wrote: > > > > > > > > > > Thanks Thiago... I didn't think it unreasonable to have fundamental ops to take code like this... > > > > > > > > > > > and have tap5 honor the same semantic (arithmetic and method calls) in some way or another... > > I refuse to violate the page code and self contained components is pure tapestry anyway. > > It seems I need chenelle... > > Can you recommend a chenelle version for tap 5.3.0 ? > > Thank You > > >
RE: dereferencing
Hey Steve, Awesome reply... Can you elaborate on your definition of ="attributes" Not sure what your calling that... syntactic, semantic or actual code... sorry if I am too conceptual... I am very excited about tap5 though... and shaking it out. - cheers Ken
outputting expression logic
Thanks Thiago... I didn't think it unreasonable to have fundamental ops to take code like this... and have tap5 honor the same semantic (arithmetic and method calls) in some way or another... I refuse to violate the page code and self contained components is pure tapestry anyway. It seems I need chenelle... Can you recommend a chenelle version for tap 5.3.0 ? Thank You
Re: Tapestry 5.3: IOCSymbols.THREAD_POOL_ENABLED does not work!?
Is this issue fixed? Anyway I can download the binaries? Thanks. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Tapestry-5-3-IOCSymbols-THREAD-POOL-ENABLED-does-not-work-tp4728718p4814755.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Gradle build failed
I do not use Maven and I am trying to build Tapestry 5.3. I got error like - TGs-MacBook-Pro:apache-tapestry-5.3.0-sources ag$ gradle FAILURE: Build failed with an exception. * Where: Build file '/Users/tg/Downloads/apache-tapestry-5.3.0-sources/build.gradle' line: 15 * What went wrong: A problem occurred evaluating root project 'apache-tapestry-5.3.0-sources'. Cause: Could not find method mavenLocal() for arguments [] on resolver container. * Try: Run with -s or -d option to get more details. Run with -S option to get the full (very verbose) stacktrace. BUILD FAILED Total time: 14.121 secs Any idea how to fix it? Or is there anyway to download the latest binaries (5.3 beta9?) anywhere for poor me? :( Thanks. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Gradle-build-failed-tp4814742p4814742.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
RE: outputting expression logic
Well I am not sure what to do... I don't want to drag multiple variables and logic and get those all rigged up in my page from the component just to do a single method... or two that take multiple parameters and reference multiple variables from within. It would be nice if we had an arithmetic operator kinda like "prop:" "math:" and maybe a function operator "func:" so i can keep all my component logic self contained. Any last ditch efforts to accommodate my dreams ? Ken > To: users@tapestry.apache.org; kcola...@live.com > Subject: Re: outputting expression logic > Date: Fri, 16 Sep 2011 07:48:41 -0300 > From: thiag...@gmail.com > > On Thu, 15 Sep 2011 23:53:18 -0300, Ken in Nashua > wrote: > > > I guess I am asking for an ognl engine... to do these calculations > > within tml files > > Are you really sure you want to have logic in your template and make it > look like JSP (which sucks), as Steve said? Mixing output generation and > logic is a recipe for confusion. When I started working with T5 I've also > missed OGNL, but later I got used to it and I use almost just property > expressions exclusively since then. > > ChenilleKit has an OGNL binding. > > > be nice if there were an expression operator in T5 to do these... > > That's not going to happen. This was dropped from T5 on purpose. > > > guess I will have to make a java method... > > This is the canonical approach. Logic belongs in Java classes. > > It does seem to me that you're trying to write T5 thinking in T4 terms. I > don't advise you to do that. The main concepts are mostly the same, but > the implementation is very, very different. > > -- > Thiago H. de Paula Figueiredo > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, > and instructor > Owner, Ars Machina Tecnologia da Informação Ltda. > http://www.arsmachina.com.br
Combination of Grid, Submit Button and Context does not work
Hi! About a year ago there was a bug regarding the usage of submit buttons with context in loops: https://issues.apache.org/jira/browse/TAP5-869 The bug was closed because using the defer parameter of the submit button fixed the problem. Now I have the same problem, but this time in a Grid rather than a loop component. Defer is set to false but every time I click on a button, only the context of the last one is used. I created a small example demonstrating the problem, it is attached to this e-mail. Try clicking on every user and watch the console output: Always the last user is printed. Is there a workaround? Is it a known bug or should I file a bug report? Regards Stephan TestGrid.tar.gz Description: application/gzip - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Datefield update causes PageAttached TAP 5.2.6
Ah, I see, thanks. Should have looked into the docs in the first place. On Sat, Sep 17, 2011 at 10:34 AM, Steve Eynon < steve.ey...@alienfactory.co.uk> wrote: > I'm not sure you can, for when you use the calendar selector, it makes > an ajax call back to the page component for parsing and formatting. Of > course, this means attaching a page to find the component! From the > DateField docs: > > * One wierd aspect here is that, because client-side JavaScript > formatting and parsing is so limited, we (currently) > * use Ajax to send the user's input to the server for parsing (before > raising the popup) and formatting (after closing > * the popup). Weird and inefficient, but easier than writing > client-side JavaScript for that purpose. > > There's another DateField component in TapX, but not having used it, I > don't know how it works. > > http://tapestry.formos.com/nightly/tapx/tapx-datefield/ > > Steve. > > > On 17 September 2011 14:29, Koka Kiknadze <226...@gmail.com> wrote: > > I have noticed that pageattached is called each time I change value in > > DateField using calendar selector but not if I manually type in the > value. > > > > What is the purpose of such behaviour and how can I avoid > > calling pageattached ? > > > > TIA > > Nicholoz > > > > TAP 5.2.6 > > > > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >