Embedding content from separate modules (a.k.a plugins)
Hi, In our application, we would like to have a modular structure, where for a certain DTO, we would like to have different tabs, depending on the actual deployed application, so the core webapp doesn't need to know all the possible tabs in advance. We have the following interface: interface TabProvider { String getTabTitle(Object obj); Block getTabComponent(Object obj); // etc ... } And we have a service, which collects all the TabProviders, filters, and displays all the provided blocks. Just we have to construct the 'Block'-s from the plugins. I've checked Tapestry, and found out (for example in PropertyDisplayBlock), this should work: class MyPlugin implements TabProvider { ComponentClassResolver resolver; RequestPageCache pageCache; public Block getTabComponent(Object obj) { String pageName = resolver.resolvePageClassNameToPageName(MyPluginTab.class.getName()); Page page = pageCache.get(pageName); return page.getRootElement().getBlock("content"); } } So far, so good. It works :) Of course, it could be just an fortunate accident. The problem occurs, when I try to pass a parameter to that block / page, as I can't modify the page or the block anyway. I've tried two things: 1, MyPluginTab tab = (MyPluginTab) page.getRootComponent(); tab.init(...); This creates a nice exception: *java.lang.ClassCastException: x.y.z.MyPluginTab cannot be cast to x.y.z.MyPluginTab * Clearly a class loader issue 2, Using the 'environment' infrastructure, so in the block embedding component: @BeforeRender void beforeRender() { environment.push(ObjSupplier.class, new ObjSupplier() { Object get() { return obj; } }); } @AfterRender void after() { environment.pop(ObjSupplier.class); } And in the MyPluginTab: @Environmental private ObjSupplier objSupplier; This seem to be work ... For the first request. On the subsequent AJAX requests, the parent component rendering is not called, so the ObjSupplier is not pushed to stack, and the page wont work any more. What should I do, to ensure that the wrapper class beforeRender/afterRender method is called? Or where else should I put the pusp/pop logic ? Or what do you think, how can I solve this problem? Thanks in advance Zsombor
Re: T5: Ajax response content-tpye
Hi, I've found a solution: overriding the AjaxPartialResponseRenderer service. In my module class I put this: public static void bind(ServiceBinder binder) { binder.bind(AjaxPartialResponseRenderer.class, StbAjaxPartialResponseRenderer.class).withId("StbAjaxPartialResponseRenderer"); } public static void contributeAliasOverrides(Configuration> configuration, @InjectService("StbAjaxPartialResponseRenderer") AjaxPartialResponseRenderer aprr) { configuration.add(AliasContribution.create(AjaxPartialResponseRenderer.class, aprr)); } And here is my StbAjaxPartialResponseRenderer class: public class AminoAjaxPartialResponseRenderer implements AjaxPartialResponseRenderer { private final MarkupWriterFactory factory; private final Request request; private final Response response; private final PartialMarkupRenderer partialMarkupRenderer; private final String outputEncoding; public AminoAjaxPartialResponseRenderer(MarkupWriterFactory factory, Request request, Response response, PartialMarkupRenderer partialMarkupRenderer, @Inject @Symbol(SymbolConstants.CHARSET) String outputEncoding) { this.factory = factory; this.request = request; this.response = response; this.partialMarkupRenderer = partialMarkupRenderer; this.outputEncoding = outputEncoding; } public void renderPartialPageMarkup() throws IOException { // This is a complex area as we are trying to keep public and private services properly // seperated, and trying to keep stateless and stateful (i.e., perthread scope) services // seperated. So we inform the stateful queue service what it needs to do here ... ContentType pageContentType = (ContentType) request.getAttribute(InternalConstants.CONTENT_TYPE_ATTRIBUTE_NAME); C*ontentType contentType = new ContentType("text/plain", outputEncoding); // The original was: ContentType contentType = new ContentType(InternalConstants.JSON_MIME_TYPE, outputEncoding);* MarkupWriter writer = factory.newPartialMarkupWriter(pageContentType); JSONObject reply = new JSONObject(); // ... and here, the pipeline eventually reaches the PRQ to let it render the root render command. partialMarkupRenderer.renderMarkup(writer, reply); PrintWriter pw = response.getPrintWriter(contentType.toString()); pw.print(reply); pw.flush(); } } This is the exact copy of the internal service class AjaxPartialResponseRendererImpl except one line. This solution works but I should not override an internal service, because if i upgrade to a new version and this service changes, my code won't work. Any better solution for my problem? I would appreciate any answer. Thank you, Zsombor Zsombor Nemestóthy wrote: Hi All! I would like to change the content-type of the ajax response, when rendering a component from an ajax request. The content-type is 'application/json' and it need to be 'plain/text'. We develop an ip-tv middleware and the setTopBox's browser (Opera gogi) can not understand the application/json content-type (I think it treats the response as binary data). I handle the ajax response with my own javascript code, so 'plain/text' would be fine. I see from the source code that the mime-type's hard coded at the InternalConstants.JSON_MIME_TYPE variable, so i don't know how to change it. Anyone has idea how to accomplish this? Regards, Zsombor - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
T5: Ajax response content-tpye
Hi All! I would like to change the content-type of the ajax response, when rendering a component from an ajax request. The content-type is 'application/json' and it need to be 'plain/text'. We develop an ip-tv middleware and the setTopBox's browser (Opera gogi) can not understand the application/json content-type (I think it treats the response as binary data). I handle the ajax response with my own javascript code, so 'plain/text' would be fine. I see from the source code that the mime-type's hard coded at the InternalConstants.JSON_MIME_TYPE variable, so i don't know how to change it. Anyone has idea how to accomplish this? Regards, Zsombor - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Tapestry 5.0.4 now available via Maven
On 5/6/07, Howard Lewis Ship <[EMAIL PROTECTED]> wrote: Once it is released, it can't be changed. Any fixes have to wait for release 5.0.5. Thems the Apache rules. Then create a new release ASAP. If it's a critical bug, don't be shy to fix it :-) I think it's common sense. BR, Zs
Re: Anyone using TACOS components in Production ?
On 5/4/07, sunilmanu <[EMAIL PROTECTED]> wrote: Hi Everyone, Is anyone currently using any of the TACOS components in Production ? I was trying some components and behaviour is different in IE & Firefox. Upload Status does not work at all. I tried the AjaxSubmitEvent for the onchange on the Select option, works fine in Firefox, but not in IE. Anyone succesffully deployed Tacos ajax into production ? (needed some motivation !!) Thanks, Sunil -- Yeah, some of us, use tacos in production environment also :) BR, Zsombor
Re: Tapestry Quickstart - Error
On 4/16/07, Andreas Andreou <[EMAIL PROTECTED]> wrote: Force an earlier version to the maven-war-plugin, i.e. open the pom.xml file and right after maven-war-plugin add 2.0.2 As mentioned before by Alexandru, you'll have to make some changes to the AppModule class, i.e. remove the Id and Contribute annotations. Thanks, I also have to modify pom.xml with the followings: org.apache.maven.plugins maven-war-plugin 2.0.2 true org.apache.maven.plugins maven-resources-plugin 2.2 org.apache.maven.plugins maven-eclipse-plugin 2.3 org.apache.maven.plugins maven-clean-plugin 2.1 And now it's works :) Thanks Zsombor
Re: Tapestry Quickstart - Error
On 4/15/07, Alexandru Dragomir <[EMAIL PROTECTED]> wrote: Are you executing mvn jetty:run inside the project folder ? (the one created by quickstart ) Cheers , Alex Yes, i run from the project folder. BR, Zsombor On 4/15/07, Zsombor < [EMAIL PROTECTED]> wrote: > > Hello, > > I've tried to follow the quickstart guide, to create a tapestry5 > projects, > the project is created by the maven archetype successfully, however > after I > try to execute mvn jetty:run it fails: > > $ mvn jetty:run > [INFO] Scanning for projects... > [INFO] Searching repository for plugin with prefix: 'jetty'. > [INFO] > > [ERROR] BUILD ERROR > [INFO] > > [INFO] Error building POM (may not be this project's POM). > > > Project ID: org.apache.maven.plugins:maven-war-plugin > > Reason: Error getting POM for 'org.apache.maven.plugins:maven-war-plugin > ' > from the repository: Failed to resolve artifact, possibly due to a > repository list that is not appropriately equipped for this artifact's > metadata. > org.apache.maven.plugins:maven-war-plugin:pom:2.0.3-SNAPSHOT > > from the specified remote repositories: > apache.snapshots ( > http://people.apache.org/repo/m2-snapshot-repository/), > howardlewisship.com ( http://howardlewisship.com/repository), > central (http://repo1.maven.org/maven2) > > > Or if I try to execute mvn compile it fails with this message : > $ mvn compile > [INFO] Scanning for projects... > [INFO] > > > [INFO] Building frontend Tapestry 5 Application > [INFO]task-segment: [compile] > [INFO] > > > [INFO] > > [ERROR] BUILD ERROR > [INFO] > > > [INFO] Error building POM (may not be this project's POM). > > > Project ID: org.apache.maven.plugins:maven-resources-plugin > > Reason: Error getting POM for ' > org.apache.maven.plugins:maven-resources-plugin ' from the repository: > Failed > to resolve artifact, possibly due to a repository list that is not > appropriately equipped for this artifact's metadata. > org.apache.maven.plugins:maven-resources-plugin:pom:2.3-SNAPSHOT > > from the specified remote repositories: > apache.snapshots ( > http://people.apache.org/repo/m2-snapshot-repository/), >howardlewisship.com (http://howardlewisship.com/repository), > central (http://repo1.maven.org/maven2) > > Has anybody seen something similar? > > BR > Zsombor >
Tapestry Quickstart - Error
Hello, I've tried to follow the quickstart guide, to create a tapestry5 projects, the project is created by the maven archetype successfully, however after I try to execute mvn jetty:run it fails: $ mvn jetty:run [INFO] Scanning for projects... [INFO] Searching repository for plugin with prefix: 'jetty'. [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error building POM (may not be this project's POM). Project ID: org.apache.maven.plugins:maven-war-plugin Reason: Error getting POM for 'org.apache.maven.plugins:maven-war-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata. org.apache.maven.plugins:maven-war-plugin:pom:2.0.3-SNAPSHOT from the specified remote repositories: apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository/), howardlewisship.com (http://howardlewisship.com/repository), central (http://repo1.maven.org/maven2) Or if I try to execute mvn compile it fails with this message : $ mvn compile [INFO] Scanning for projects... [INFO] [INFO] Building frontend Tapestry 5 Application [INFO]task-segment: [compile] [INFO] [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error building POM (may not be this project's POM). Project ID: org.apache.maven.plugins:maven-resources-plugin Reason: Error getting POM for ' org.apache.maven.plugins:maven-resources-plugin' from the repository: Failed to resolve artifact, possibly due to a repository list that is not appropriately equipped for this artifact's metadata. org.apache.maven.plugins:maven-resources-plugin:pom:2.3-SNAPSHOT from the specified remote repositories: apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository/), howardlewisship.com (http://howardlewisship.com/repository), central (http://repo1.maven.org/maven2) Has anybody seen something similar? BR Zsombor