Re: Rendering cache
Hi, one of my simple implementation, hope it helps. public abstract class StaticCacheComponent { private final static int CACHE_EXPIRED = 60; @Inject private ComponentResources componentResources; @Inject private CacheService cacheService; @Inject private TypeCoercer typeCoercer; private Element fakeElement = null; private String cacheId = null; final boolean beginRender(MarkupWriter writer) { InternalComponentResourcesImpl resourcesImpl = (InternalComponentResourcesImpl)componentResources; StringBuilder builder = new StringBuilder(this.getClass().getSimpleName()); for (String parameterName : resourcesImpl.getComponentModel().getParameterNames()) { boolean isBound = resourcesImpl.isBound(parameterName); String parameterValueStr = null; if (isBound) { parameterValueStr = typeCoercer.coerce(resourcesImpl.getBinding(parameterName).get(), String.class); } builder.append(parameterName).append("_").append(parameterValueStr).append("_"); } cacheId = builder.toString(); String staticCache = cacheService.getCache(cacheId, getCacheExpired()); if (staticCache != null) { writer.writeRaw(staticCache); return false; } else { fakeElement = writer.element("span"); return true; } } final void afterRenderTemplate(MarkupWriter writer) { writer.end(); // must call before removing String innerHTMl = fakeElement.getChildMarkup(); fakeElement.remove(); writer.writeRaw(innerHTMl); cacheService.saveCache(cacheId, getCacheExpired(), innerHTMl); } protected int getCacheExpired() { return CACHE_EXPIRED; } } 2012/7/28 Jens Breitenstein > Hi T5'ers > > we have some performance issues and started thinking about caching our > pages (lets say parts of them to be precise). Due to the fact we are > showing user related information along with "public information" on a page, > we can not make use of a simple web proxy caching. > > Therefore we are thinking about a "component rendering result cache". > > Assume we have several independent components to show an overview of items > (and we have a lot of items rendered in a loop) and we want to cache the > rendering result of one of these particular components for several seconds > before rendering it again (to reflect new items or changes). I am aware > this means we are showing stale data for some seconds, but honestly this is > not an issue because after rendering and displaying it in the browser data > is considerably old anyway :-) > > What might be a good place to intercept the rendering and store the output > from a component and on the other hand use outputraw for sending cached > data? > Does anyone tried this before? > > Any idea or comment is appreciated, thanks in advance > > > Jens > > > > > --**--**- > To unsubscribe, e-mail: > users-unsubscribe@tapestry.**apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: Howto render a block and put it into a JSON reply?
Hi, To render block as html markup, I did like this: public String renderMarkup(RenderCommand renderCommand) { MarkupWriter markupWriter = new MarkupWriterImpl(); // validation track ValidationDecorator decorator = new DefaultValidationDecorator(environment, assetSource.getExpandedAsset("${tapestry.spacer-image}"), markupWriter); environment.push(ValidationDecorator.class, decorator); RenderQueueImpl renderQueue = new RenderQueueImpl(logger); renderQueue.push(renderCommand); renderQueue.run(markupWriter); environment.pop(ValidationDecorator.class); return markupWriter.toString().replaceAll("^\\n+", "").replaceAll("\\n+$", ""); } and call renderMarkup((RenderCommand )block). Not sure whether it is better than yours, hope it helps. 2012/2/16 Christian Riedel > Hi there, > > I'm trying to improve the tapestry5-jquery DataTable component, which is > able to respond paged results in JSON. Unfortunately the component is a bit > limited in terms of what can be returned. I want to add support for the > Grid-style p:propertyCell block-parameter-notation. > I'm looking for the most elegant way to do it. Currently I'm trying it > with faked zone updates (ajaxResponseRenderer.addRender) and a filter > (ajaxResponseRenderer.addFilter) that should modify the JSON reply object. > It feels very clumsy and I thought if someone on the list could point me to > a more elegant solution. > > More Abstract: > We've got > - an Ajax callback: void onData() { ... } > - PropertyOverrides, having block parameters > - a working data source that is able to fetch data by the current page > > We need > - loop over all rows of the current page and > - render each cell's content or its override into a row-json-array and > - put each row-json-array into a data json-array > > Is there another way than using ajaxResponseRenderer.addRender / addFilter? > > Cheers > Christian > - > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
Re: T5.1 locale switch back to default english after navigate to other page
Hi, If you switch locale by PersistentLocale service, I think the locale will be persisted. Thanks, DH 2011/11/18 wesleywj2 > hi there, > > i successfully switch the locale between english and chinese "zh_CN" within > a page, but encountered a problem where once i switch to chinese and > navigate to other pages with actionlink,submit etc, the other page switched > back to default english. how do i keep the locale persisted for all pages > after locale switching? > > please advice, > wesleywj2 > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/T5-1-locale-switch-back-to-default-english-after-navigate-to-other-page-tp5002303p5002303.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: [ANNOUNCE] Apache Tapestry preview 5.3-rc-1
A pleasure! Done. https://issues.apache.org/jira/browse/TAP5-1741 Thanks, DH 2011/11/1 Howard Lewis Ship > It is possible, can you open up a JIRA issue and attach your template? > > On Tue, Nov 1, 2011 at 3:01 AM, dh ning wrote: > > Me too where tml contains Chinese words. > > > > Should be caused by the html5 doc type changes? > > > > Caused by: java.io.UTFDataFormatException: Invalid byte 3 of 3-byte UTF-8 > > sequence. > >at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown > Source) > >at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source) > >at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source) > >at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown > > Source) > >at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown > > Source) > >at > > org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown > > Source) > >at > > org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown > > Source) > >at > > > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown > > Source) > >at > > > org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown > > Source) > >at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > > Source) > >at org.apache.xerces.parsers.XML11Configuration.parse(Unknown > > Source) > >at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) > >at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown > Source) > >at > > > org.apache.tapestry5.internal.services.XMLTokenStream.parse(XMLTokenStream.java:306) > >at > > > org.apache.tapestry5.internal.services.SaxTemplateParser.parse(SaxTemplateParser.java:163) > > > > > > 2011/11/1 Donyee > > > >> Both rc-1 and rc-2, I got this " Invalid byte 1 of 1-byte UTF-8 > sequence." > >> but works fine with beta-26 > >> is there any new changes?? > >> > >> > >> > >> 2011/11/1 Howard Lewis Ship > >> > >> > Uh, yes. It's been a trying afternoon. > >> > > >> > On Mon, Oct 31, 2011 at 3:26 PM, Muhammad Gelbana < > m.gelb...@gmail.com> > >> > wrote: > >> > > You mean 5.3-rc-2 I suppose. > >> > > >
Re: [ANNOUNCE] Apache Tapestry preview 5.3-rc-1
Me too where tml contains Chinese words. Should be caused by the html5 doc type changes? Caused by: java.io.UTFDataFormatException: Invalid byte 3 of 3-byte UTF-8 sequence. at org.apache.xerces.impl.io.UTF8Reader.invalidByte(Unknown Source) at org.apache.xerces.impl.io.UTF8Reader.read(Unknown Source) at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source) at org.apache.xerces.impl.XMLEntityScanner.scanLiteral(Unknown Source) at org.apache.xerces.impl.XMLScanner.scanAttributeValue(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanAttribute(Unknown Source) at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) at org.apache.tapestry5.internal.services.XMLTokenStream.parse(XMLTokenStream.java:306) at org.apache.tapestry5.internal.services.SaxTemplateParser.parse(SaxTemplateParser.java:163) 2011/11/1 Donyee > Both rc-1 and rc-2, I got this " Invalid byte 1 of 1-byte UTF-8 sequence." > but works fine with beta-26 > is there any new changes?? > > > > 2011/11/1 Howard Lewis Ship > > > Uh, yes. It's been a trying afternoon. > > > > On Mon, Oct 31, 2011 at 3:26 PM, Muhammad Gelbana > > wrote: > > > You mean 5.3-rc-2 I suppose. > > > > > > On Mon, Oct 31, 2011 at 11:32 PM, Howard Lewis Ship > >wrote: > > > > > >> FYI: I found a minor problem in Tapestry 5.2-rc-1 and am > > >> building/uploading Tapestry 5.2-rc-2 right now. > > >> > > >> On Mon, Oct 31, 2011 at 11:05 AM, Howard Lewis Ship > > > >> wrote: > > >> > We are very pleased to announce the first release candidate preview > of > > >> > Tapestry 5.3. > > >> > > > >> > Tapestry 5.3 is significantly faster than Tapestry 5.2, and is more > > >> > memory efficient ... a long with tons of significant new features, > > >> > improvements, and bug fixes. > > >> > > > >> > Details here: > > >> > > http://tapestry.apache.org/2011/10/31/tapestry-53-release-candidate.html > > >> > > > >> > This is still a preview release, but we encourage the Tapestry > > >> > community to upgrade to this release. With positive feedback (and no > > >> > show-stopping negative feedback) we should progress to a final > release > > >> > of 5.3 in a few weeks. > > >> > > > >> > For most users, the upgrade path is simply changing the version > > >> > number, and performing a clean compile. > > >> > > > >> > Note that with each new release, we get a slew of panicked messages > > >> > that Tapestry is broken in bizarre ways. These ALMOST ALWAYS turn > out > > >> > to be prior-release JARs still on the classpath, either in the > > >> > developer's working directory, or in a servlet container deployment > > >> > directory. Please carefully clean up your environment as part of the > > >> > upgrade! > > >> > > > >> > There are some cases where Tapestry 5.3 performs more rigorous > checks > > >> > than Tapestry 5.2; for example, 5.3 ensures that event handler > methods > > >> > that reference a component id ("onSuccessFromLogin") correspond to > an > > >> > actual component ("login"); in Tapestry 5.2, this was not checked > for, > > >> > and the event handler method would never fire ... it likely has a > typo > > >> > in its name, or is related to a component that was removed from the > > >> > template. This particular check can be disabled: > > >> > > > >> > > > http://tapestry.apache.org/configuration.html#Configuration-tapestry.compatibility.unknowncomponentidcheck > > . > > >> .. > > >> > > > >> > It would be wise to start up your application under 5.3, then use > the > > >> > new PageCatalog page (http://localhost:8080/pagecatalog) and click > > the > > >> > "load all" link, to force all pages to be loaded. This will quickly > > >> > identify any coding problems in your application. > > >> > > > >> > -- > > >> > Howard M. Lewis Ship > > >> > > > >> > Creator of Apache Tapestry > > >> > > > >> > The source for Tapestry training, mentoring and support. Contact me > to > > >> > learn how I can get you up and productive in Tapestry fast! > > >> > > > >> > (971) 678-5210 > > >> > http://howardlewisship.com > > >> > > > >> > > >> > > >> > > >> -- > > >> Howard M. Lewis Ship > > >> > > >> Creator of Apache Tapestry > > >> > > >> The source for Tapestry training, mentoring and support. Contact me to > > >> learn how I can get you up and productive in Tapestry fast! > > >> > > >> (971) 678-5210 > > >> http://howardlewisship.com > > >> > > >> --
T5: Critial security of t:formdata
Hi, These days I always think of security of t:formdata, just now I have a test to hack the t:formdata and find there is some serious damages. 1. First I change source code of Form component and store a component action in Form and build my own tapestry-core.jar. static final ComponentAction TEST_ACTION = new ComponentAction() { private static final long serialVersionUID = 0L; public void execute(Form component) { for (int i = 0; i < 1000; i++) { System.out.println("-run " + i); } } @Override public String toString() { return "TEST_ACTION"; } }; 2. Jetty:run the application with my own jar and access one page (/login) that contains form, then get the t:formdata from html source code. 3. Revert offical jar, and new a AbstractIntegrationTestSuite test case: open("login"); type("t:formdata", copy the form data from 2nd); clickAndWait(submit); Test result: I can see "-run 0" to "-run 1000" loged. So in my understanding, doesn't it mean that website based on tapestry5 is not very secured and can be attacked by any experienced t5 programmer? Thanks, DH
Why Grid component fetches data one more time in form submit
Hi, When Grid is in a form, even though 'volatile' parameter is set to 'false' (by default), I can see the datasource provider method is called during form submit. My understanding is that, if 'volatile' is false, it should not be called in form submitted, am I missing something? Object setupRender() { if (formSupport != null) formSupport.store(this, SETUP_DATA_SOURCE); ... } >From the source code of Grid.java, if Grid is in form, the SETUP_DATA_SOURCE componentaction is always called after form submitted. I think 'volatile' should be here to prevent it from calling during submit. Unfortunately 'volatile' parameter is now declared as publishParameters of GridRows component. How do you handle grid component in a form? Thanks, DH
stylesheet processing in ajax response doesn't work in firefox3.0
Hi, Environment: tapestry 5.0.18, firefox3.0, maven jetty:run Whenever there is new stylesheet link in ajax response in firefox3.0 (both 3.0.5&3.0.6), then there is an ajax error shown in top of page "Client exception processing response: TypeError: existing is null". But IE 6&7, firefox 2.0 work well. Major code of test case like following: Page.tml Page.java @Component private Zone abcZone; public Object onActionFromLink() { return abcZone; } AjaxWindow.java @IncludeStylesheet(value = {"context:css/themes/default.css"}) public class WindowPanel { } If I remove @IncludeStylesheet annotation, then it works well in firefox3.0 too. Is it a known issue of firefox3.0 or tapestry.js code issue? Any workaround for this? Thanks, DH
Re: [T5] 5.0.16 Spanish special characters
That's true, native2ascii is unnecessarily any more. Try to locate the issue whether it is caused at server side or by html page encoding. What's that value in tapestry page.java level? If it is correct, then this should be the html encoding problem. 2008/12/4 Thiago H. de Paula Figueiredo <[EMAIL PROTECTED]> > Em Wed, 03 Dec 2008 14:58:39 -0300, Imants Firsts <[EMAIL PROTECTED]> > escreveu: > > Hi Ray! >> >> The properties files should be in ascii encoding and the unicode >> characters should be escaped with \u, for example "\u0161" for ลก >> character. JDK comes with native2ascii tool that does the conversion. >> > > That's not correct anymore. Since some Tapestry version I don't recall, the > property files need to be UTF-8 encoded, so no conversion needs to be done. > > From http://tapestry.apache.org/tapestry5/guide/localization.html: > > "Properties File Charset > > Tapestry uses the UTF-8 charset when reading the properties files in a > message catalog. This means that you don't have to use the Java native2ascii > tool." > > > -- > Thiago H. de Paula Figueiredo > Independent Java consultant, developer, and instructor > Consultor, desenvolvedor e instrutor em Java > http://www.arsmachina.com.br/thiago > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >
Re: [T5] Page naigation using submit
You don't want the component rely on page, but you do (rely on outer form, right?), so if you want your component handle event independently, set the form in the component is a must. btw, onSelect's signature should only be Void type. DH 2008/10/17 Ville Virtanen <[EMAIL PROTECTED]> > > Yep, that's exactly the case. > > The component can't rely on any code in the page, so solution number 1 is > out of the question. > > Solution number 2 throws exception: > Event 'selected' from FinancePlan:dynamicfromcont. received an event > handler method return value of > [EMAIL PROTECTED] This type of event does > not > support return values from event handler methods. > > - Ville > > > dhning-2 wrote: > > > > From your former mail, my understanding on your case (correct me if I am > > wrong): your page has a form, and the form contains your component, and > > your component template has multiple submit buttons (it must be submit > > component if you want to handle select event). > > > > I think there are two ways: > > 1. Inside the page java, handle the onAction/onSuccess event. (You can > not > > see the onSelect event here) > > 2. Inside your component java, handle the onSelect event (I am not sure > > whether it is right, I haven't tried before) > > > > Thanks! > > > > DH > > - Original Message - > > From: "Ville Virtanen" <[EMAIL PROTECTED]> > > To: > > Sent: Friday, October 17, 2008 8:08 PM > > Subject: Re: [T5] Page naigation using submit > > > > > >> > >> Yes it must be, otherwise it won't work. > >> > >> The submit event that is triggered by the form in the page does not > >> bubble > >> to my component and I can't use the selected event triggered by the > >> button > >> in my component because that event does not support return type of page > >> class. > >> > >> - Ville > >> > >> > >> dhning-2 wrote: > >>> > >>> But your component must be enclosed by an outer form component, right? > >>> Or > >>> else, how can you put textfield in your component? > >>> > >>> Thanks! > >>> > >>> DH > >>> > >>> > >>> - Original Message - > >>> From: "Ville Virtanen" <[EMAIL PROTECTED]> > >>> To: > >>> Sent: Friday, October 17, 2008 7:01 PM > >>> Subject: [T5] Page naigation using submit > >>> > >>> > > Hi, > > This must be discussed before, but I could not find anything using > search > and I seem to be having total brain freeze here so: > > I have a case where I have to let user enter rows to a view and there > must > be an "Edit" function at the end of each of these rows. The edit > functionality MUST SUBMIT before redirecting to detail edit as every > row > in > the view are editable, and user may edit the rows, after which > she/he/it > clicks the edit button to edit the details of a row. > > So, how can I use submit to redirect to the detail page. As this is a > component, I cannot do the normal "onSuccess" redirect, as my > component > does > not define form and hence it doesn't receive the on submit event. > > I think it is pretty standard to have a button to redirect to another > page > after submit. > > Am I missing something totally obvious? > > - Ville > -- > View this message in context: > > http://www.nabble.com/-T5--Page-naigation-using-submit-tp20031177p20031177.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] > > > >>> > >> > >> -- > >> View this message in context: > >> > http://www.nabble.com/-T5--Page-naigation-using-submit-tp20031177p20032020.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] > >> > >> > > > > -- > View this message in context: > http://www.nabble.com/-T5--Page-naigation-using-submit-tp20031177p20032647.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] > >
An exception at jetty starts up while using classNameLocator
Hi, I got an exception when Jetty starts up after my maven repository updates to the latest tapestry 5.0.15-snapshot(I haven't update my repository for about 3 weeks), the latest 5.0.14-snapshot can't work too. The exception is: [ERROR] ClassNameLocator Construction of service ClassNameLocator failed: Error invoking constructor org.apache.tapestry5.ioc.internal.services.ClassNameLocatorImpl(ClasspathURLConverter) (at ClassNameLocatorImpl.java:61) (for service 'ClassNameLocator'): Exception constructing service 'Alias': Construction of service 'Alias' has failed due to recursion: the service depends on itself in some way. Please check org.apache.tapestry5.services.TapestryModule.buildAlias(Logger, String, AliasManager, Collection) (at TapestryModule.java:207) for references to another service that is itself dependent on service 'Alias'. I find the cause is the usage of ClassNameLocator in my AppModule.java. It is very simple. public class AppModule { public static void contributeTypeCoercer( Configuration configuration, final ClassNameLocator classNameLocator) { classNameLocator.locateClassNames("com.mycompany.entities"); other codes } } If I comment classNameLocator.locateClassNames("com.mycompany.entities"), then everything works and Jetty starts up. Please help on solving the problem. It blocks me for several days. Thanks. DH
Re: Problem wuth internacionalization
Hi, What's your tapestry version? If is the latest version, you should not put the start.tml, start.properties in WEB-INF. They should be in parent level of WEB-INF(src/main/webapp/) or in /src/main/resources/com/igno/bookStore/pages/. And for app.properties, it should be always in WEB-INF. Thanks! DH 2008/5/13, Igoor <[EMAIL PROTECTED]>: > > > when i make files Start.properties and Start_de.properties and put them > into > WEB-INF, or when i make com.igor.bookStore.pages and put these files into > this root my application doesen't work... But when I make files > app.properties and app_de.properties into WEB-INF whit same content like > Start.properties and Start_de.properties my application work. What i need > to > do in order to make my application work with Start.properties and > Start_de.properties > -- > View this message in context: > http://www.nabble.com/Problem-wuth-internacionalization-tp17190006p17190006.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] > >
Is it possible to prevent the render method in parent component from being invoked?
Hi, First I know it is a feature that parent method is prior to child's. I need to extend GridPager component because the action link in GridPager doesn't have a context parameter, so the context info of the link is very limited(only the page No.). And I don't like to persist context in session. The case is that in a user list page with search function and Grid component, user input keyword username, role and so on, and then click 'search' button, the relevant result will be shown in a Grid's page 1, but when user clicks page 2, the search keyword is missing, then the result is wrong which is not expected. So I extend GridPager to provide context to actionlink, but because it (as parent) implements a method beginRender() which is always invoked by Tapestry5 ahead of my GridPager's beginRender(), so now there would be two pager generated in list page. So is there a way to prevent the render method in parent from being invoked? And how? And what's the best practice here dealing with search funcion with Grid? Anyone please share your experience. Thanks in advance. DH