Re: How to add a link to a file stored in directory?

2013-06-05 Thread Lance Java
Tapestry has built in support for serving classpath assets.
http://tapestry.apache.org/assets.html

Option1
TML
   a
href=${asset:classpath:regoznapp/enterprise/src/main/resources/return.txt}
/

Option2
Java
@Inject AssetSource assetSource;

   public String getAssetUrl() {
  return
assetSource.getClasspathAsset(regoznapp/enterprise/src/main/resources/return.txt,
null).toClientURL();
   }

TML
   a href=${assetUrl}  /


Re: Tapestry 5.4-alpha-7

2013-06-05 Thread Muhammad Gelbana
1. I hope this comment would be considered to solve that issue.

https://issues.apache.org/jira/browse/TAP5-1948?focusedCommentId=13675755page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13675755

*2. In development mode, Tapestry monitors all assets that have been
exposed to
the client: CSS files, JavaScript libraries, and so forth. When any file
changes, all sorts of caches are cleared.*
*
*
You must be talking about a cache on the server's side. But how would that
work if the client caches tapestry assets aggressively ? Or would that
aggressive client caching be forced only while in production mode ?

Thanks.


On Mon, Jun 3, 2013 at 8:04 PM, Howard Lewis Ship hls...@gmail.com wrote:

 The latest Tapestry preview release, 5.4-alpha-7, adds a little bit of
 development-time caching to compilation of CoffeeScript and Less assets.

 The new version is available at the following Maven repository:

 https://repository.apache.org/content/repositories/orgapachetapestry-057/

 In development mode, Tapestry monitors all assets that have been exposed to
 the client: CSS files, JavaScript libraries, and so forth. When any file
 changes, all sorts of caches are cleared.

 In normal Tapestry, this is not very noticeable; Tapestry quickly reloads
 all the necessary files (changed or not).

 Unfortunately, the CoffeeScript compiler is currently limited by the use of
 Rhino, the slow JavaScript VM built into the JVM. It can take many seconds
 to compile a CoffeeScript file.

 alpha-7 introduces a special cache for CoffeeScript and Less; this cache is
 based on file content, not date-time-modified (though, as I write this, I'm
 wondering if a date-time-modified check would work just as well as the
 content check). In any case, this cache is not cleared with the other
 caches. When a file has been previously compiled, and its source has not
 changed, the compiled version is vended out of the cache.

 For Less files, it is smart enough to track the main source file, but also
 any files that are read via the @import mechanism built into Less.

 As a test, I copied the Bootstrap Less source files into my test
 application, and reconfigured Tapestry to use this bootstrap.less in place
 of the normal bootstrap.css bundled with the framework.  Results were quite
 reasonable:

 qtp1995297012-16 [INFO] StreamableResourceSource Compiled
 context:bootstrap/css/bootstrap.less to Less in 5229.39 ms
 qtp1995297012-16 [INFO] ResourceMinimizer Minimized
 context:bootstrap/css/bootstrap.less (124,827 input bytes of text/css to
 100,793 output bytes in 3056.71 ms, 19.25% reduction)

 I consider being able to dynamically build Bootstrap from its Less source,
 and minimize its content, at runtime, to be a bellwether that the
 Less/JavaScript/CSS/Minimization support is going to work well for
 production applications.

 --
 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.3.7] Tapestry archtype dependencies

2013-06-05 Thread Muhammad Gelbana
Why tapestry archtype project, when generated using maven and imported into
Eclipse, has much more dependencies than the ones separately downloadable
from tapestry's portal ?


Re: [t5.3.7] Tapestry archtype dependencies

2013-06-05 Thread Thiago H. de Paula Figueiredo
Are you talking about any JAR downloaded by Maven or just the ones put in
the generated project classpath? If, for example, your .m2/repository
folder didn't exist or wasn't populated yet, Maven will download lots of
stuff used by itself.


On Wed, Jun 5, 2013 at 7:45 AM, Muhammad Gelbana m.gelb...@gmail.comwrote:

 Why tapestry archtype project, when generated using maven and imported into
 Eclipse, has much more dependencies than the ones separately downloadable
 from tapestry's portal ?




-- 
Thiago


Re: [t5.3.7] Tapestry archtype dependencies

2013-06-05 Thread Muhammad Gelbana
I'm talking about the generated classpath. I understand from your answer
that this is not possible or should not happen ?
I guess these libraries are for maven's sake as you suggested.

Thank you.


On Wed, Jun 5, 2013 at 1:44 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 Are you talking about any JAR downloaded by Maven or just the ones put in
 the generated project classpath? If, for example, your .m2/repository
 folder didn't exist or wasn't populated yet, Maven will download lots of
 stuff used by itself.


 On Wed, Jun 5, 2013 at 7:45 AM, Muhammad Gelbana m.gelb...@gmail.com
 wrote:

  Why tapestry archtype project, when generated using maven and imported
 into
  Eclipse, has much more dependencies than the ones separately downloadable
  from tapestry's portal ?
 



 --
 Thiago



Re: [t5.3.7] Tapestry archtype dependencies

2013-06-05 Thread Thiago H. de Paula Figueiredo
Which libraries are being added which you consider useless? Don't forget
that dependencies may have dependencies themselves, so Maven (or any other
tool that handles dependencies) has to deal with that too. In Eclipse, in
the POM editor, there's a dependency graph you can check. Of mvn
dependency:tree in command line (I'm not sure that's the exact command).
And no, Maven doesn't add its own dependencies to the generated classpath
of any projects, just the one your project declares in one way or another.


On Wed, Jun 5, 2013 at 8:56 AM, Muhammad Gelbana m.gelb...@gmail.comwrote:

 I'm talking about the generated classpath. I understand from your answer
 that this is not possible or should not happen ?
 I guess these libraries are for maven's sake as you suggested.

 Thank you.


 On Wed, Jun 5, 2013 at 1:44 PM, Thiago H. de Paula Figueiredo 
 thiag...@gmail.com wrote:

  Are you talking about any JAR downloaded by Maven or just the ones put in
  the generated project classpath? If, for example, your .m2/repository
  folder didn't exist or wasn't populated yet, Maven will download lots of
  stuff used by itself.
 
 
  On Wed, Jun 5, 2013 at 7:45 AM, Muhammad Gelbana m.gelb...@gmail.com
  wrote:
 
   Why tapestry archtype project, when generated using maven and imported
  into
   Eclipse, has much more dependencies than the ones separately
 downloadable
   from tapestry's portal ?
  
 
 
 
  --
  Thiago
 




-- 
Thiago


Re: [t5.3.7] Tapestry archtype dependencies

2013-06-05 Thread Muhammad Gelbana
I can't remember the classpath entries generated by maven as I've disabled
maven dependencies but I remember seeing Apache xerces !

I guess maven just follow each dependency's dependencies in it's pom and
downloads\includes it automatically. Whats weird is that tapestry's
downloaded jars and dependencies are way lot less than what maven
downloaded\included.

But I guess it's just the way that maven works that makes it look weird to
me as I'm successfully working with tapestry's downloaded jars.


On Wed, Jun 5, 2013 at 2:08 PM, Thiago H. de Paula Figueiredo 
thiag...@gmail.com wrote:

 Which libraries are being added which you consider useless? Don't forget
 that dependencies may have dependencies themselves, so Maven (or any other
 tool that handles dependencies) has to deal with that too. In Eclipse, in
 the POM editor, there's a dependency graph you can check. Of mvn
 dependency:tree in command line (I'm not sure that's the exact command).
 And no, Maven doesn't add its own dependencies to the generated classpath
 of any projects, just the one your project declares in one way or another.


 On Wed, Jun 5, 2013 at 8:56 AM, Muhammad Gelbana m.gelb...@gmail.com
 wrote:

  I'm talking about the generated classpath. I understand from your answer
  that this is not possible or should not happen ?
  I guess these libraries are for maven's sake as you suggested.
 
  Thank you.
 
 
  On Wed, Jun 5, 2013 at 1:44 PM, Thiago H. de Paula Figueiredo 
  thiag...@gmail.com wrote:
 
   Are you talking about any JAR downloaded by Maven or just the ones put
 in
   the generated project classpath? If, for example, your .m2/repository
   folder didn't exist or wasn't populated yet, Maven will download lots
 of
   stuff used by itself.
  
  
   On Wed, Jun 5, 2013 at 7:45 AM, Muhammad Gelbana m.gelb...@gmail.com
   wrote:
  
Why tapestry archtype project, when generated using maven and
 imported
   into
Eclipse, has much more dependencies than the ones separately
  downloadable
from tapestry's portal ?
   
  
  
  
   --
   Thiago
  
 



 --
 Thiago



Re: [t5.3.7] Tapestry archtype dependencies

2013-06-05 Thread Thiago H de Paula Figueiredo
On Wed, 05 Jun 2013 10:12:59 -0300, Muhammad Gelbana m.gelb...@gmail.com  
wrote:


I can't remember the classpath entries generated by maven as I've  
disabled maven dependencies but I remember seeing Apache xerces !


Weird. I've never seen it in a Tapestry project.


I guess maven just follow each dependency's dependencies in it's pom and
downloads\includes it automatically.


That's exactly what a dependency tool does.


Whats weird is that tapestry's
downloaded jars and dependencies are way lot less than what maven
downloaded\included.


There's at least one huge difference: the Tapestry downloaded JARs (from  
Tapestry website) don't include Hibernate and its dependencies (which are  
quite a few), for example, as its license (non ASL-compatible) prevents it.


But I guess it's just the way that maven works that makes it look weird  
to me as I'm successfully working with tapestry's downloaded jars.


Agreed.

--
Thiago H. de Paula Figueiredo

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Contribute multiple collections in the same service?

2013-06-05 Thread Ferran Maylinch
Thank you,

In my case, MapConfig contributions can be reduced to HazelcastConfigurer
contributions (and now I see I should have used the latter from the start)
so (to avoid many refactorings) I created another service that converts
MapConfig contributions to a HazelcastConfigurer.

public class MapConfigServiceImpl implements MapConfigService
{
private final CollectionMapConfig mapConfigs;
 private final Logger logger;

 public MapConfigServiceImpl(CollectionMapConfig mapConfigs, Logger
logger)
 {
this.mapConfigs = mapConfigs;
 this.logger = logger;
}

@Override
 public HazelcastConfigurer getHazelcastConfigurer()
{
 return new HazelcastConfigurer()
{
 @Override
public void configure(Config config)
 {
for (MapConfig mapConfig : mapConfigs)
 {
logger.info(Configuring map:  + mapConfig.getName());
 config.addMapConfig(mapConfig);
}
 }
};
 }
}


And in the module:

@Contribute(HazelcastConfigService.class)
 public static void contributeConfigurerForMapConfigs(
MapConfigService mapConfigService,
 ConfigurationHazelcastConfigurer hzConfigurers)
{
 hzConfigurers.add( mapConfigService.getHazelcastConfigurer() );
}



On Tue, Jun 4, 2013 at 12:50 PM, Ferran Maylinch
ferranmayli...@gmail.comwrote:

 Hello,

 I would like to contribute 2 collections to a service, but I am afraid
 Tapestry only supports one collection to be contributed. Am I right?

 My service constructor is like this:

 public HazelcastConfigServiceImpl(
  final CollectionMapConfig mapConfigs,
 final CollectionHazelcastConfigurer hzConfigurers) { ... }

 And I try to contribute the hzConfigurers this way:

 @Contribute(HazelcastConfigService.class)
  public static void
 contributeExecutorConfig(ConfigurationHazelcastConfigurer hzConfigurers)
  {
 hzConfigurers.add(new HazelcastConfigurer()
  {
 @Override
  public void configure(Config config)
 {
  config.addExecutorConfig(
 new ExecutorConfig(RankingsConstants.RANKINGS_EXECUTOR_SERVICE_NAME)
  .setCorePoolSize(5)
 .setMaxPoolSize(5)
  );
 }
  });
 }

 But I get this exception:

 Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could not
 find a coercion from type
 com.mobivery.malcom.categories.rankings.workers.services.MalcomRankingsWorkersModule$1
 to type com.hazelcast.config.MapConfig.

 It seems it is trying to insert my HazelcastConfigurer into
 the mapConfigs when it should go to the hzConfigurers.

 Thank you

 -- Ferran



Re: Contribute multiple collections in the same service?

2013-06-05 Thread Lance Java
You don't need the MapConfigService, you can use a serviceId (or a marker
annotation) to disambiguate your HazelcastConfigurer instances.

// serviceId = mapConfigHazelcastConfigurer
public HazelcastConfigurer buildMapConfigHazelcastConfigurer(final
CollectionMapConfig mapConfigs) {
   return new HazelcastConfigurer {
  public void configure(Config config) {
 for (MapConfig mapConfig : mapConfigs) {
config.addMapConfig(mapConfig);
 }
  }
   };
}

public void
contributeMapConfigHazelcastConfigurer(ConfigurationHazelcastConfigurer
config) {
   config.add(new MapConfig(...));
   config.add(new MapConfig(...));

}

public static void contributeHazelcastConfigService(
   ConfigurationHazelcastConfigurer config,
@ServiceId(mapConfigHazelcastConfigurer) HazelcastConfigurer
mapConfigHazelcastConfigurer
{
   config.add(mapConfigHazelcastConfigurer);
}


Re: [t5] Is it possible to return a component's generated HTML ?

2013-06-05 Thread Muhammad Gelbana
Honestly, I can't figure out anything from these 2 resources ! It all looks
so complicated to me.

@Dmitry
What is the entry point of your code ? When an ajaxrequest is sent to my
application, doesn't it reach your CompanyBlocks page ? Then when does
all the other services begin working ?!

@Lanve
And I thought Dimitry's code was complicated :D
Your code was even harder to look at, I also can't understand the entry
point and the flow of data starting when I receive an ajax request till I
respond with a string representation of a component's template file.

Thank you all for your help :)


On Thu, May 30, 2013 at 6:41 PM, Lance Java lance.j...@googlemail.comwrote:

 I'm not 100% sure what your implementation will be but I've done some work
 in this area.

 Take a look at PDFLink.getFoAsString() where I convert a RenderCommand to a
 String of markup (XML in the example)

 http://tapestry-stitch.uklance.cloudbees.net/pdflinkdemo

 Also, take a look at this wiki entry


 http://wiki.apache.org/tapestry/Tapestry5HowToGetAnHTMLStringFromARenderCommandParameter

 Note that a Block can be type coerced to a RenderCommand



Re: [t5] Is it possible to return a component's generated HTML ?

2013-06-05 Thread Lance Java
I think I need to understand how it's going to work before I go any further.



Here's one approach

1. The browser makes a request to the other webapp

2. The other webapp makes request(s) to the tapestry app

3. The other webapp merges it's own html with the tapestry html to create a
page

4. The page is returned to the user



Here's another approach

1. The browser makes a request to the other webapp

2. The other webapp returns a page with some empty divs

3. Some javascript runs on page load

4. The browser makes requests to the tapestry app

5. The tapestry app returns responses to the browser

6. Some javascript in the browser updates the innerHTML of some div's



In both approaches, you are going to be fighting an uphill battle if you
want to handle javascript and eventlink / actionlinks in your tapestry
components. If you simply want to render html fragments, without links or
javascript we might be able to help.


Re: [t5] Is it possible to return a component's generated HTML ?

2013-06-05 Thread Dmitry Gusev
The entry point is:

String rawAddress = renderer.render(new RenderEvent(
internal/companyblocks, companyAddress, company));


You tell here that onCompanyAddress method (or method with
@Event(companyAddress)) should be invoked on the internal/companyblocks page
class and if that method returns a Block - it will be rendered to a string.
company - is a parameter to that method that you may use to initialize
rendering context for the block.
You can also not return Block from the method by just addRenderer:

ajaxResponseRenderer.addRender(addressBlockZone);

And the addressBlockZone will be rendered to as string in this case.

Resulting string will be serialized json object, so you can inspect its
structure and take the content you want like:

String htmlAddress = new JSONObject(rawAddress).getString(content);


On Wed, Jun 5, 2013 at 8:14 PM, Muhammad Gelbana m.gelb...@gmail.comwrote:

 Honestly, I can't figure out anything from these 2 resources ! It all looks
 so complicated to me.

 @Dmitry
 What is the entry point of your code ? When an ajaxrequest is sent to my
 application, doesn't it reach your CompanyBlocks page ? Then when does
 all the other services begin working ?!

 @Lanve
 And I thought Dimitry's code was complicated :D
 Your code was even harder to look at, I also can't understand the entry
 point and the flow of data starting when I receive an ajax request till I
 respond with a string representation of a component's template file.

 Thank you all for your help :)


 On Thu, May 30, 2013 at 6:41 PM, Lance Java lance.j...@googlemail.com
 wrote:

  I'm not 100% sure what your implementation will be but I've done some
 work
  in this area.
 
  Take a look at PDFLink.getFoAsString() where I convert a RenderCommand
 to a
  String of markup (XML in the example)
 
  http://tapestry-stitch.uklance.cloudbees.net/pdflinkdemo
 
  Also, take a look at this wiki entry
 
 
 
 http://wiki.apache.org/tapestry/Tapestry5HowToGetAnHTMLStringFromARenderCommandParameter
 
  Note that a Block can be type coerced to a RenderCommand
 




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


RE: Grid Component subsequent submit causes IndexOutofBoundsException

2013-06-05 Thread nhhockeyplayer nashua
Thanks Thiago...

The collection was always being populated. It still is nicely. There seems to 
be some confusion on persisted form properties and ajax with regard to what the 
grid is doing under the hood.

I failed to have a complete usable prototype by June 1st with 
http://powerplayhockey.noip.us:9011/pphl/home 

so
The users opted to go with 
http://www.hometeamsonline.com/sportswebsites/?
for $300 per year

Did Microsoft win ? I wonder. Thanks for helping out.

Best regards 
and thanks... KEN

From: nhhockeypla...@hotmail.com
To: users@tapestry.apache.org
Subject: RE: Grid Component subsequent submit causes IndexOutofBoundsException
Date: Mon, 3 Jun 2013 02:43:16 -0400




If I could get some assistance I would really appreciate.

I am using Dmitry's favored strategy of connecting pages using blocks.

Some facts... I persist my form select properties to they maintain state 
across submit calls. Since I removed @Persist ... thats not happening (it wuold 
be nice on how to persist form properties across submit calls)

But the real stuff thats making me worried... is

0. setupRender never gets called when i initially display the block (I am not 
sure what to do here)
1. when I click GO for a submit.. my collection gets populated from the 
database nicely... but somehow... setupRender gets called after my submit. ??? 
not sure what to think at this point. because I am under the impression that 
setupRender gets called once. maybe its the arrangement of blocks and pages? I 
dont know.
2. after setupRender completes executing... my form finishes rendering... but 
the grid is empty and the collection somehow was emptied before the grid could 
get its hands on it

and this is my collection

@Persist
@Property
private Collection collection;

and this is my grid routine

public GridDataSource getSource() {
if (collection != null) 
return new CollectionGridDataSource(collection);
else
return new CollectionGridDataSource(Collections.emptyList());
}

any help understasnding whats happening to my grid would be greatly appreciated.

and what i can do to supplement a solution.

thank you
Ken

  

Re: Tapestry 5.4-alpha-7

2013-06-05 Thread Howard Lewis Ship
On Wed, Jun 5, 2013 at 2:51 AM, Muhammad Gelbana m.gelb...@gmail.comwrote:

 1. I hope this comment would be considered to solve that issue.


 https://issues.apache.org/jira/browse/TAP5-1948?focusedCommentId=13675755page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-13675755

 *2. In development mode, Tapestry monitors all assets that have been
 exposed to
 the client: CSS files, JavaScript libraries, and so forth. When any file
 changes, all sorts of caches are cleared.*
 *
 *
 You must be talking about a cache on the server's side. But how would that
 work if the client caches tapestry assets aggressively ? Or would that
 aggressive client caching be forced only while in production mode ?

 Thanks.


Assets now have a content hash embedded into the URL; if a server-side
asset changes, then the URL Tapestry generates for that asset will change
as well, and the browser will pull the new content.

In production mode, Tapestry assumes the assets are static, and wastes no
resources  on checking to see if they have changed. It assumes that change
will come in the form of a complete redeployment and relaunch of the WAR.

In development mode, extra filters and logic come into play to check for
changes to assets.

URLs for modules can't include a version number, so those don't get a far
future expires header, but they (as of alpha-9) get a Cache-Control that
forces the browser to revalidate them on each new page render.




 On Mon, Jun 3, 2013 at 8:04 PM, Howard Lewis Ship hls...@gmail.com
 wrote:

  The latest Tapestry preview release, 5.4-alpha-7, adds a little bit of
  development-time caching to compilation of CoffeeScript and Less assets.
 
  The new version is available at the following Maven repository:
 
 
 https://repository.apache.org/content/repositories/orgapachetapestry-057/
 
  In development mode, Tapestry monitors all assets that have been exposed
 to
  the client: CSS files, JavaScript libraries, and so forth. When any file
  changes, all sorts of caches are cleared.
 
  In normal Tapestry, this is not very noticeable; Tapestry quickly reloads
  all the necessary files (changed or not).
 
  Unfortunately, the CoffeeScript compiler is currently limited by the use
 of
  Rhino, the slow JavaScript VM built into the JVM. It can take many
 seconds
  to compile a CoffeeScript file.
 
  alpha-7 introduces a special cache for CoffeeScript and Less; this cache
 is
  based on file content, not date-time-modified (though, as I write this,
 I'm
  wondering if a date-time-modified check would work just as well as the
  content check). In any case, this cache is not cleared with the other
  caches. When a file has been previously compiled, and its source has not
  changed, the compiled version is vended out of the cache.
 
  For Less files, it is smart enough to track the main source file, but
 also
  any files that are read via the @import mechanism built into Less.
 
  As a test, I copied the Bootstrap Less source files into my test
  application, and reconfigured Tapestry to use this bootstrap.less in
 place
  of the normal bootstrap.css bundled with the framework.  Results were
 quite
  reasonable:
 
  qtp1995297012-16 [INFO] StreamableResourceSource Compiled
  context:bootstrap/css/bootstrap.less to Less in 5229.39 ms
  qtp1995297012-16 [INFO] ResourceMinimizer Minimized
  context:bootstrap/css/bootstrap.less (124,827 input bytes of text/css to
  100,793 output bytes in 3056.71 ms, 19.25% reduction)
 
  I consider being able to dynamically build Bootstrap from its Less
 source,
  and minimize its content, at runtime, to be a bellwether that the
  Less/JavaScript/CSS/Minimization support is going to work well for
  production applications.
 
  --
  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


Re: [t5] Is it possible to return a component's generated HTML ?

2013-06-05 Thread Muhammad Gelbana
Actually Lance's second approach is what I need to do. And yes it should be
very simple, I will only have to display regular html without controls at
all (Hopefully it will stay this way and I actually think it will)

Regards


On Wed, Jun 5, 2013 at 8:00 PM, Dmitry Gusev dmitry.gu...@gmail.com wrote:

 The entry point is:

 String rawAddress = renderer.render(new RenderEvent(
 internal/companyblocks, companyAddress, company));


 You tell here that onCompanyAddress method (or method with
 @Event(companyAddress)) should be invoked on the internal/companyblocks
 page
 class and if that method returns a Block - it will be rendered to a string.
 company - is a parameter to that method that you may use to initialize
 rendering context for the block.
 You can also not return Block from the method by just addRenderer:

 ajaxResponseRenderer.addRender(addressBlockZone);

 And the addressBlockZone will be rendered to as string in this case.

 Resulting string will be serialized json object, so you can inspect its
 structure and take the content you want like:

 String htmlAddress = new
 JSONObject(rawAddress).getString(content);


 On Wed, Jun 5, 2013 at 8:14 PM, Muhammad Gelbana m.gelb...@gmail.com
 wrote:

  Honestly, I can't figure out anything from these 2 resources ! It all
 looks
  so complicated to me.
 
  @Dmitry
  What is the entry point of your code ? When an ajaxrequest is sent to my
  application, doesn't it reach your CompanyBlocks page ? Then when does
  all the other services begin working ?!
 
  @Lanve
  And I thought Dimitry's code was complicated :D
  Your code was even harder to look at, I also can't understand the entry
  point and the flow of data starting when I receive an ajax request till I
  respond with a string representation of a component's template file.
 
  Thank you all for your help :)
 
 
  On Thu, May 30, 2013 at 6:41 PM, Lance Java lance.j...@googlemail.com
  wrote:
 
   I'm not 100% sure what your implementation will be but I've done some
  work
   in this area.
  
   Take a look at PDFLink.getFoAsString() where I convert a RenderCommand
  to a
   String of markup (XML in the example)
  
   http://tapestry-stitch.uklance.cloudbees.net/pdflinkdemo
  
   Also, take a look at this wiki entry
  
  
  
 
 http://wiki.apache.org/tapestry/Tapestry5HowToGetAnHTMLStringFromARenderCommandParameter
  
   Note that a Block can be type coerced to a RenderCommand
  
 



 --
 Dmitry Gusev

 AnjLab Team
 http://anjlab.com



Re: [t5] Is it possible to return a component's generated HTML ?

2013-06-05 Thread Dmitry Gusev
If you only need to get HTML on the client and not on the server-side,
then you may just use Tapestry's built-in logic for handling AJAX requests.

On the server side create eventLink:

Link link = resources.createEventLink(eventType, contextValues);
return link.toAbsoluteURI();

Pass this link to client side during rendering and when needed do the AJAX
calls using, say, jQuery.ajax.

You may handle ajax request on the server side the same way I wrote in my
example above --
return block from event handler or use ajaxResponseRenderer.addRender().
On the client-side response will be the same JSON and you may extract
content from it.

Note that in both cases it is possible to render multiple blocks by one
request -- this is if you call
ajaxResponseRenderer.addRender() multiple times.


On Thu, Jun 6, 2013 at 1:12 AM, Muhammad Gelbana m.gelb...@gmail.comwrote:

 Actually Lance's second approach is what I need to do. And yes it should be
 very simple, I will only have to display regular html without controls at
 all (Hopefully it will stay this way and I actually think it will)

 Regards


 On Wed, Jun 5, 2013 at 8:00 PM, Dmitry Gusev dmitry.gu...@gmail.com
 wrote:

  The entry point is:
 
  String rawAddress = renderer.render(new RenderEvent(
  internal/companyblocks, companyAddress, company));
 
 
  You tell here that onCompanyAddress method (or method with
  @Event(companyAddress)) should be invoked on the internal/companyblocks
  page
  class and if that method returns a Block - it will be rendered to a
 string.
  company - is a parameter to that method that you may use to initialize
  rendering context for the block.
  You can also not return Block from the method by just addRenderer:
 
  ajaxResponseRenderer.addRender(addressBlockZone);
 
  And the addressBlockZone will be rendered to as string in this case.
 
  Resulting string will be serialized json object, so you can inspect its
  structure and take the content you want like:
 
  String htmlAddress = new
  JSONObject(rawAddress).getString(content);
 
 
  On Wed, Jun 5, 2013 at 8:14 PM, Muhammad Gelbana m.gelb...@gmail.com
  wrote:
 
   Honestly, I can't figure out anything from these 2 resources ! It all
  looks
   so complicated to me.
  
   @Dmitry
   What is the entry point of your code ? When an ajaxrequest is sent to
 my
   application, doesn't it reach your CompanyBlocks page ? Then when
 does
   all the other services begin working ?!
  
   @Lanve
   And I thought Dimitry's code was complicated :D
   Your code was even harder to look at, I also can't understand the entry
   point and the flow of data starting when I receive an ajax request
 till I
   respond with a string representation of a component's template file.
  
   Thank you all for your help :)
  
  
   On Thu, May 30, 2013 at 6:41 PM, Lance Java lance.j...@googlemail.com
   wrote:
  
I'm not 100% sure what your implementation will be but I've done some
   work
in this area.
   
Take a look at PDFLink.getFoAsString() where I convert a
 RenderCommand
   to a
String of markup (XML in the example)
   
http://tapestry-stitch.uklance.cloudbees.net/pdflinkdemo
   
Also, take a look at this wiki entry
   
   
   
  
 
 http://wiki.apache.org/tapestry/Tapestry5HowToGetAnHTMLStringFromARenderCommandParameter
   
Note that a Block can be type coerced to a RenderCommand
   
  
 
 
 
  --
  Dmitry Gusev
 
  AnjLab Team
  http://anjlab.com
 




-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com