Re: RequireJS Shim and JavaScriptModuleConfiguration

2014-06-18 Thread Sanket Sharma
Nope. Doesn't work. I have my javascript files in the project under
resources resources/META-INF/modules/ol/ol.js

Does it map the META-INF/modules to a virtual resource? In your code I'm as
suing there is a folder under META-INF called assets/js?

If I use @Path(/META-INF/modules/ol/ol.js) corresponding to my folder
structure it fails with the error below:
Unable to locate asset 'classpath:modules.gz/modules/ol/ol.js' (the file
does not exist).

In the deployed file, it seems all javascript files are gzipped under
context-root/modules.gz And thats where its loading all the javascript from.






On Wed, Jun 18, 2014 at 3:41 AM, Geoff Callender 
geoff.callender.jumpst...@gmail.com wrote:

 Here's one that worked, producing a module called jquery-ui:

 public static void contributeModuleManager(MappedConfigurationString,
 Object configuration,
 @Path(/META-INF/assets/js/jquery-ui-1.9.1.js) Resource
 jqueryUi) {
 configuration.add(jquery-ui, new
 JavaScriptModuleConfiguration(jqueryUi));
 }

 HTH,

 Geoff

 On 18 Jun 2014, at 10:25 am, Sanket Sharma sanketsha...@gmail.com wrote:

  Hi,
 
  How do I convert a non AMD javascript module to work with require.js?
 
  I did some investigate and it seems like shimming is the way to go.
  I would like to take a javascript file ol.js and shim to to export 'ol'.
  The file is located under modules and is packaged in META-INF/modules
  directory in the standard tapestry way.
 
  Reading source code and documentation seems to suggest it can be done in
  the following way:
 
  @Contribute(ModuleManager.class)
  public static void setupOpenLayersConfiguration(
  MappedConfigurationString, Object mappedConfiguration,
  @Inject @Path(classpath:META-INF/modules/ol/ol.js) Resource ol) {
  JavaScriptModuleConfiguration openLayers = new
  JavaScriptModuleConfiguration(ol);
  openLayers.exports(ol);
  mappedConfiguration
  .add(ol, openLayers);
  }
 
  What is the correct syntax to refer to inject this file as a resource?
 The
  above class path syntax seems to be failing.
 
  Is there a pure Javascript way as well? Been trying to play with
  config/shim blocks but couldn't get it working.
 
  Any help would be appreciated.
 
  Best Regards,
  Sanket




Re: RequireJS Shim and JavaScriptModuleConfiguration

2014-06-18 Thread Geoff Callender
ol.js is not a module, it's an asset. That's why you're shimming it. So instead 
of putting it in resources/META-INF/modules/, try putting it in 
resources/META-INF/assets/js/.

On 18 Jun 2014, at 5:11 pm, Sanket Sharma sanketsha...@gmail.com wrote:

 Nope. Doesn't work. I have my javascript files in the project under
 resources resources/META-INF/modules/ol/ol.js
 
 Does it map the META-INF/modules to a virtual resource? In your code I'm as
 suing there is a folder under META-INF called assets/js?
 
 If I use @Path(/META-INF/modules/ol/ol.js) corresponding to my folder
 structure it fails with the error below:
 Unable to locate asset 'classpath:modules.gz/modules/ol/ol.js' (the file
 does not exist).
 
 In the deployed file, it seems all javascript files are gzipped under
 context-root/modules.gz And thats where its loading all the javascript from.
 
 
 
 
 
 
 On Wed, Jun 18, 2014 at 3:41 AM, Geoff Callender 
 geoff.callender.jumpst...@gmail.com wrote:
 
 Here's one that worked, producing a module called jquery-ui:
 
public static void contributeModuleManager(MappedConfigurationString,
 Object configuration,
@Path(/META-INF/assets/js/jquery-ui-1.9.1.js) Resource
 jqueryUi) {
configuration.add(jquery-ui, new
 JavaScriptModuleConfiguration(jqueryUi));
}
 
 HTH,
 
 Geoff
 
 On 18 Jun 2014, at 10:25 am, Sanket Sharma sanketsha...@gmail.com wrote:
 
 Hi,
 
 How do I convert a non AMD javascript module to work with require.js?
 
 I did some investigate and it seems like shimming is the way to go.
 I would like to take a javascript file ol.js and shim to to export 'ol'.
 The file is located under modules and is packaged in META-INF/modules
 directory in the standard tapestry way.
 
 Reading source code and documentation seems to suggest it can be done in
 the following way:
 
 @Contribute(ModuleManager.class)
 public static void setupOpenLayersConfiguration(
 MappedConfigurationString, Object mappedConfiguration,
 @Inject @Path(classpath:META-INF/modules/ol/ol.js) Resource ol) {
 JavaScriptModuleConfiguration openLayers = new
 JavaScriptModuleConfiguration(ol);
 openLayers.exports(ol);
 mappedConfiguration
 .add(ol, openLayers);
 }
 
 What is the correct syntax to refer to inject this file as a resource?
 The
 above class path syntax seems to be failing.
 
 Is there a pure Javascript way as well? Been trying to play with
 config/shim blocks but couldn't get it working.
 
 Any help would be appreciated.
 
 Best Regards,
 Sanket
 
 


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



Re: RequireJS Shim and JavaScriptModuleConfiguration

2014-06-18 Thread Sanket Sharma
Okay, it works if I place my javascript under /META-INF/assets/js

Bug? Or does everything have to be under assets? It doesn't seem to pick up
resources under META-INF/modules.


On Wed, Jun 18, 2014 at 9:11 AM, Sanket Sharma sanketsha...@gmail.com
wrote:


 Nope. Doesn't work. I have my javascript files in the project under
 resources resources/META-INF/modules/ol/ol.js

 Does it map the META-INF/modules to a virtual resource? In your code I'm
 as suing there is a folder under META-INF called assets/js?

 If I use @Path(/META-INF/modules/ol/ol.js) corresponding to my folder
 structure it fails with the error below:
 Unable to locate asset 'classpath:modules.gz/modules/ol/ol.js' (the file
 does not exist).

 In the deployed file, it seems all javascript files are gzipped under
 context-root/modules.gz And thats where its loading all the javascript from.






 On Wed, Jun 18, 2014 at 3:41 AM, Geoff Callender 
 geoff.callender.jumpst...@gmail.com wrote:

 Here's one that worked, producing a module called jquery-ui:

 public static void
 contributeModuleManager(MappedConfigurationString, Object configuration,
 @Path(/META-INF/assets/js/jquery-ui-1.9.1.js) Resource
 jqueryUi) {
 configuration.add(jquery-ui, new
 JavaScriptModuleConfiguration(jqueryUi));
 }

 HTH,

 Geoff

 On 18 Jun 2014, at 10:25 am, Sanket Sharma sanketsha...@gmail.com
 wrote:

  Hi,
 
  How do I convert a non AMD javascript module to work with require.js?
 
  I did some investigate and it seems like shimming is the way to go.
  I would like to take a javascript file ol.js and shim to to export 'ol'.
  The file is located under modules and is packaged in META-INF/modules
  directory in the standard tapestry way.
 
  Reading source code and documentation seems to suggest it can be done in
  the following way:
 
  @Contribute(ModuleManager.class)
  public static void setupOpenLayersConfiguration(
  MappedConfigurationString, Object mappedConfiguration,
  @Inject @Path(classpath:META-INF/modules/ol/ol.js) Resource ol) {
  JavaScriptModuleConfiguration openLayers = new
  JavaScriptModuleConfiguration(ol);
  openLayers.exports(ol);
  mappedConfiguration
  .add(ol, openLayers);
  }
 
  What is the correct syntax to refer to inject this file as a resource?
 The
  above class path syntax seems to be failing.
 
  Is there a pure Javascript way as well? Been trying to play with
  config/shim blocks but couldn't get it working.
 
  Any help would be appreciated.
 
  Best Regards,
  Sanket





Re: RequireJS Shim and JavaScriptModuleConfiguration

2014-06-18 Thread Geoff Callender
Not a bug. 
If you put actual modules in resources/META-INF/modules/, then they work fine. 
Put non-modules in resources/META-INF/assets/ and make them available as 
modules as I showed below by contributing to ModuleManager.

On 18 Jun 2014, at 5:27 pm, Sanket Sharma sanketsha...@gmail.com wrote:

 Okay, it works if I place my javascript under /META-INF/assets/js
 
 Bug? Or does everything have to be under assets? It doesn't seem to pick up
 resources under META-INF/modules.
 
 
 On Wed, Jun 18, 2014 at 9:11 AM, Sanket Sharma sanketsha...@gmail.com
 wrote:
 
 
 Nope. Doesn't work. I have my javascript files in the project under
 resources resources/META-INF/modules/ol/ol.js
 
 Does it map the META-INF/modules to a virtual resource? In your code I'm
 as suing there is a folder under META-INF called assets/js?
 
 If I use @Path(/META-INF/modules/ol/ol.js) corresponding to my folder
 structure it fails with the error below:
 Unable to locate asset 'classpath:modules.gz/modules/ol/ol.js' (the file
 does not exist).
 
 In the deployed file, it seems all javascript files are gzipped under
 context-root/modules.gz And thats where its loading all the javascript from.
 
 
 
 
 
 
 On Wed, Jun 18, 2014 at 3:41 AM, Geoff Callender 
 geoff.callender.jumpst...@gmail.com wrote:
 
 Here's one that worked, producing a module called jquery-ui:
 
public static void
 contributeModuleManager(MappedConfigurationString, Object configuration,
@Path(/META-INF/assets/js/jquery-ui-1.9.1.js) Resource
 jqueryUi) {
configuration.add(jquery-ui, new
 JavaScriptModuleConfiguration(jqueryUi));
}
 
 HTH,
 
 Geoff
 
 On 18 Jun 2014, at 10:25 am, Sanket Sharma sanketsha...@gmail.com
 wrote:
 
 Hi,
 
 How do I convert a non AMD javascript module to work with require.js?
 
 I did some investigate and it seems like shimming is the way to go.
 I would like to take a javascript file ol.js and shim to to export 'ol'.
 The file is located under modules and is packaged in META-INF/modules
 directory in the standard tapestry way.
 
 Reading source code and documentation seems to suggest it can be done in
 the following way:
 
 @Contribute(ModuleManager.class)
 public static void setupOpenLayersConfiguration(
 MappedConfigurationString, Object mappedConfiguration,
 @Inject @Path(classpath:META-INF/modules/ol/ol.js) Resource ol) {
 JavaScriptModuleConfiguration openLayers = new
 JavaScriptModuleConfiguration(ol);
 openLayers.exports(ol);
 mappedConfiguration
 .add(ol, openLayers);
 }
 
 What is the correct syntax to refer to inject this file as a resource?
 The
 above class path syntax seems to be failing.
 
 Is there a pure Javascript way as well? Been trying to play with
 config/shim blocks but couldn't get it working.
 
 Any help would be appreciated.
 
 Best Regards,
 Sanket
 
 
 


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



Re: IoC / Multiple Implementations

2014-06-18 Thread Lance Java
I don't think there's anything stopping you from binding a List as a
service.

Since list is a common class, you will probably want to use marker
annotations or @InjectService to disambiguate.

Both approaches are discussed here:
http://tapestry.apache.org/defining-tapestry-ioc-services.html
 On 17 Jun 2014 22:06, Michael Leuthold michael.leuth...@gmail.com
wrote:

 Well, the scenario is a simple service-interface that returns a JSON
 array to configure a Javascript component. And depending on the input,
 the content of the JSON array looks different, that's why there are
 multiple implementations. Usually we iterate over the implementations
 and take the first result that is not null - and I just noticed that's
 exactly what the ChainBuilder does! It hides quite a bunch and does
 'magic' :/ but I'll give it a try. I think Lances pointer to the
 OrderedConfiguration looks quite useful, too and is basically the key
 - I'll see what plays out best.

 However, with the given options it's a little more overhead to
 hand-craft the implementations to build the configuration but this
 should be do-able. Though think it would be more intuitive to just
 have the List injected from whatever is registered with the Binder.

 Thanks,
 Michael



 On Tue, Jun 17, 2014 at 8:51 PM, Lance Java lance.j...@googlemail.com
 wrote:
  I tend to do the following:
 
  public interface FooProvider {
 ListFoo getFoos();
  }
 
  @UsesOrderedConfiguration(Foo.class)
  public class FooProviderImpl implements FooProvider {
 private final ListFoo foos;
 public FooProviderImpl(ListFoo foos) { this.foos = foos; }
 public ListFoo getFoos() { return foos; }
  }
 
  Then you can @Contribute to the FooProvider to add to the list and
 @Inject
  the FooProvider wherever you need the list.
 
 
 
  On 17 June 2014 18:21, Thiago H de Paula Figueiredo thiag...@gmail.com
  wrote:
 
  On Tue, 17 Jun 2014 09:54:24 -0300, Michael Leuthold 
  michael.leuth...@gmail.com wrote:
 
   Hello,
 
  I am currently stuck with the following problem: I try to inject a
  list of implementations of a certain interface but it seems it does
  not work using the straight approach of injecting a
  ListSomeInterface impls
 
  Though implementations exist and a list is injected but it's just
  empty. Does anyone have a hint where to look here? Maybe I need to
  register that list explicitly.
 
 
  Tapestry-IoC doesn't support that, at least not yet. What's your
 scenario?
  Usually, when we need more than one implementation of a given
 interface, we
  create a pipeline (
 http://tapestry.apache.org/pipelinebuilder-service.html)
  or chain (http://tapestry.apache.org/chainbuilder-service.html) to
  consolidate all these implementations as a single service. Or you can
  create a service that receives these service implementations as its
  distributed configuration and acts as a locator for it.
 
  --
  Thiago H. de Paula Figueiredo
  Tapestry, Java and Hibernate consultant and developer
  http://machina.com.br
 
 
  -
  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




Re: RequireJS Shim and JavaScriptModuleConfiguration

2014-06-18 Thread Sanket Sharma
*enlightenment*

:-)
On 18 Jun 2014 09:34, Geoff Callender geoff.callender.jumpst...@gmail.com
wrote:

 Not a bug.
 If you put actual modules in resources/META-INF/modules/, then they work
 fine.
 Put non-modules in resources/META-INF/assets/ and make them available as
 modules as I showed below by contributing to ModuleManager.

 On 18 Jun 2014, at 5:27 pm, Sanket Sharma sanketsha...@gmail.com wrote:

  Okay, it works if I place my javascript under /META-INF/assets/js
 
  Bug? Or does everything have to be under assets? It doesn't seem to pick
 up
  resources under META-INF/modules.
 
 
  On Wed, Jun 18, 2014 at 9:11 AM, Sanket Sharma sanketsha...@gmail.com
  wrote:
 
 
  Nope. Doesn't work. I have my javascript files in the project under
  resources resources/META-INF/modules/ol/ol.js
 
  Does it map the META-INF/modules to a virtual resource? In your code I'm
  as suing there is a folder under META-INF called assets/js?
 
  If I use @Path(/META-INF/modules/ol/ol.js) corresponding to my folder
  structure it fails with the error below:
  Unable to locate asset 'classpath:modules.gz/modules/ol/ol.js' (the file
  does not exist).
 
  In the deployed file, it seems all javascript files are gzipped under
  context-root/modules.gz And thats where its loading all the javascript
 from.
 
 
 
 
 
 
  On Wed, Jun 18, 2014 at 3:41 AM, Geoff Callender 
  geoff.callender.jumpst...@gmail.com wrote:
 
  Here's one that worked, producing a module called jquery-ui:
 
 public static void
  contributeModuleManager(MappedConfigurationString, Object
 configuration,
 @Path(/META-INF/assets/js/jquery-ui-1.9.1.js) Resource
  jqueryUi) {
 configuration.add(jquery-ui, new
  JavaScriptModuleConfiguration(jqueryUi));
 }
 
  HTH,
 
  Geoff
 
  On 18 Jun 2014, at 10:25 am, Sanket Sharma sanketsha...@gmail.com
  wrote:
 
  Hi,
 
  How do I convert a non AMD javascript module to work with require.js?
 
  I did some investigate and it seems like shimming is the way to go.
  I would like to take a javascript file ol.js and shim to to export
 'ol'.
  The file is located under modules and is packaged in META-INF/modules
  directory in the standard tapestry way.
 
  Reading source code and documentation seems to suggest it can be done
 in
  the following way:
 
  @Contribute(ModuleManager.class)
  public static void setupOpenLayersConfiguration(
  MappedConfigurationString, Object mappedConfiguration,
  @Inject @Path(classpath:META-INF/modules/ol/ol.js) Resource ol) {
  JavaScriptModuleConfiguration openLayers = new
  JavaScriptModuleConfiguration(ol);
  openLayers.exports(ol);
  mappedConfiguration
  .add(ol, openLayers);
  }
 
  What is the correct syntax to refer to inject this file as a resource?
  The
  above class path syntax seems to be failing.
 
  Is there a pure Javascript way as well? Been trying to play with
  config/shim blocks but couldn't get it working.
 
  Any help would be appreciated.
 
  Best Regards,
  Sanket
 
 
 


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




Re: WebSocket for tapestry

2014-06-18 Thread Bogdan Ivascu
1. No errors in JavaScript
2. I'm using 5.3.6
3. I did, all work ok and do not lose their ability to do ajax calls.

The problem is as you guessed it. I changed the javascript like so and it
works perfectly:

tapestry-atmosphere.js
...
if (pushTarget.update == 'PREPEND') {
var insertion = new Hash();
insertion.set('top', content);
element.insert(insertion.toJSON());
...

Thanks for the reply.





On Tue, Jun 17, 2014 at 4:28 AM, Lance Java lance.j...@googlemail.com
wrote:

 I'm starting to think this is caused by the js prepend function. It's
 simply:

   element.innerHTML = newHtml + element.innerHTML.

 I think this function needs to be smarter and do a dom based element
 addition rather than a String addition.

 I tried to avoid using prototype or jquery so it was agnostic so just did a
 quick and dirty string concat. I can see this would cause the problem.
  On 16 Jun 2014 23:22, Bogdan Ivascu ivascu.bogdan...@gmail.com wrote:

  That did it. Sorry to keep hitting this nail but, I stumbled across
 another
  one. As described above, the push targets will prepend a block on every
  update. Inside this bock, I have eventLinks that are rendered correctly
  after I put in the configuration. These eventLinks are supposed to be
 ajax.
  The eventLink rendered with the last block correctly calls the page via
  ajax, however all other eventLinks in blocks already displayed no longer
  make ajax calls. It looks as if they get deregistered somehow from the
  Tapestry onClick handler that makes ajax calls.
 
  Thanks.
 
 
  On Mon, Jun 16, 2014 at 3:40 AM, Lance Java lance.j...@googlemail.com
  wrote:
 
   See the configuration section here
   https://github.com/uklance/tapestry-offline
   On 16 Jun 2014 05:44, Bogdan Ivascu ivascu.bogdan...@gmail.com
  wrote:
  
Makes sense, thanks for the reply.
   
Another thing that is odd. I seem to have trouble while rendering
eventLinks inside a block that is a delagate of a pushTarget.
   
in tml:
atmos:pushTarget ...
t:delegate to=tokenPlayHistoryBlock/
/atmos:pushTarget
   
t:block t:id=tokenPlayedByUser
a bunch of html markup
/t:block
   
in the java class
public Block getTokenPlayHistoryBlock(){
   switch based on conditions
  retun blockXXX;
}
   
Above works great until I try to add an eventLink in block:
   
t:block t:id=tokenPlayedByUser
   a bunch of html markup
a t:id=sentTokenPreviewLinkTHIS BREAKS IT/a
/t:block
   
Error:
2014-Jun-16 00:29:09
 ioc.internal.RecursiveServiceCreationCheckWrapper
org.apache.tapestry5.ioc.internal.OperationException: *Symbol
'tapestry-offline.serverName' is not defined.*
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.services.MasterObjectProviderImpl.provide(MasterObjectProviderImpl.java:45)
at $MasterObjectProvider_23570e7547da.provide(Unknown Source)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.getObject(RegistryImpl.java:871)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.ObjectLocatorImpl.getObject(ObjectLocatorImpl.java:57)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateInjection(InternalUtils.java:257)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils.access$000(InternalUtils.java:50)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:289)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils$4.invoke(InternalUtils.java:286)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils.calculateParameters(InternalUtils.java:293)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1488)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.util.InternalUtils$23.invoke(InternalUtils.java:1483)
at
   
   
  
 
 org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
at
   
   
  
 
 

Redirecting to a page from a MethodAdvice implementation

2014-06-18 Thread Davide Vecchi
Hello,
I have the following class to handle the execution of methods that are 
annotated with a custom @ExceptionDisplay annotation. Everything works as 
expected, but I would like to redirect to a page. I'm using 
PageRenderLinkSource and Response to do that. I inject them in the same way I 
usually inject them into pages, but in this case it does not work, because the 
PageRenderLinkSource and Response instances are both null. I imagine that's 
because they should be only injected into pages or components, so I'm wondering 
if / how is it possible to redirect to a page from a MethodAdvice. Thanks in 
advance for any possible suggestion.


ExceptionDisplayWorker.java


package tapestry.util.annotations;

import java.io.IOException;

import org.apache.tapestry5.Link;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.model.MutableComponentModel;
import org.apache.tapestry5.plastic.MethodAdvice;
import org.apache.tapestry5.plastic.MethodInvocation;
import org.apache.tapestry5.plastic.PlasticClass;
import org.apache.tapestry5.plastic.PlasticMethod;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.Response;
import org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;

import tapestry.pages.ExceptionDisplayPage;
import tapestry.annotations.ExceptionDisplay;

public class ExceptionDisplayWorker implements ComponentClassTransformWorker2
{
   private final MethodAdvice advice = new MethodAdvice()
{
  @Inject
  private PageRenderLinkSource pageRenderLinkSource;

  @Inject
  private Response response;

@Override
public void advise(MethodInvocation invocation)
{
System.out.println(this.pageRenderLinkSource + ; + 
this.response); // Both null.

MethodInvocation result = invocation.proceed();

if (result.didThrowCheckedException())
{
 Exception exception = 
result.getCheckedException(Exception.class);

 exception.printStackTrace();

 // Redirect to the exception page :

 result.setCheckedException(null);

 Link exceptionDisplayPage = 
this.pageRenderLinkSource.createPageRenderLink(ExceptionDisplayPage.class); // 
Problem here, pageRenderLinkSource is null.

 try
{
   this.response.sendRedirect(exceptionDisplayPage); // 
Problem here too, response is null too.

}
catch (IOException e)
{
   e.printStackTrace();
}
}
}
};

   @Override
   public void transform(PlasticClass plasticClass, TransformationSupport 
support, MutableComponentModel model)
   {
  for (PlasticMethod method : 
plasticClass.getMethodsWithAnnotation(ExceptionDisplay.class))
  {
 method.addAdvice(this.advice);
  }
   }
}


-


Re: Redirecting to a page from a MethodAdvice implementation

2014-06-18 Thread Thiago H de Paula Figueiredo

On Wed, 18 Jun 2014 11:47:16 -0300, Davide Vecchi d...@amc.dk wrote:


Hello,


Hi!

I have the following class to handle the execution of methods that are  
annotated with a custom @ExceptionDisplay annotation. Everything works  
as expected, but I would like to redirect to a page. I'm using  
PageRenderLinkSource and Response to do that. I inject them in the same  
way I usually inject them into pages, but in this case it does not work,  
because the PageRenderLinkSource and Response instances are both null. 
I   imagine that's because they should be only injected into pages or  
components,


You're right, but you forgot include Tapestry-IoC services and objects  
instantiated using ObjectLocator.autobuild().


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



RE: Redirecting to a page from a MethodAdvice implementation

2014-06-18 Thread Davide Vecchi
Hi,

Sorry, I don't understand. Do you mean that I'm right that PageRenderLinkSource 
and Response should be only injected into pages or  components ?

Could you elaborate a little bit about including Tapestry-IoC services and 
objects  instantiated using ObjectLocator.autobuild() ?


Re: Redirecting to a page from a MethodAdvice implementation

2014-06-18 Thread Thiago H de Paula Figueiredo

On Wed, 18 Jun 2014 12:01:16 -0300, Davide Vecchi d...@amc.dk wrote:


Hi,


Hi!

Sorry, I don't understand. Do you mean that I'm right that  
PageRenderLinkSource and Response should be only injected into pages or   
components ?


Nope. I said it can be injected into pages, components, mixins,  
Tapestry-IoC services and objects returned by ObjectLocator.autobuild().


Could you elaborate a little bit about including Tapestry-IoC services  
and objects  instantiated using ObjectLocator.autobuild() ?


I meant including as being in the list of stuff that gets injections  
done.


--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

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



Re: Redirecting to a page from a MethodAdvice implementation

2014-06-18 Thread Lance Java
As a simple rule, if you instantiated the object yourself, @Inject won't
work.

See here:
private final MethodAdvice advice = new MethodAdvice() ...

You've used new so it's not under tapestry's control.
 Hello,
I have the following class to handle the execution of methods that are
annotated with a custom @ExceptionDisplay annotation. Everything works as
expected, but I would like to redirect to a page. I'm using
PageRenderLinkSource and Response to do that. I inject them in the same way
I usually inject them into pages, but in this case it does not work,
because the PageRenderLinkSource and Response instances are both null. I
imagine that's because they should be only injected into pages or
components, so I'm wondering if / how is it possible to redirect to a page
from a MethodAdvice. Thanks in advance for any possible suggestion.


ExceptionDisplayWorker.java


package tapestry.util.annotations;

import java.io.IOException;

import org.apache.tapestry5.Link;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.model.MutableComponentModel;
import org.apache.tapestry5.plastic.MethodAdvice;
import org.apache.tapestry5.plastic.MethodInvocation;
import org.apache.tapestry5.plastic.PlasticClass;
import org.apache.tapestry5.plastic.PlasticMethod;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.apache.tapestry5.services.Response;
import
org.apache.tapestry5.services.transform.ComponentClassTransformWorker2;
import org.apache.tapestry5.services.transform.TransformationSupport;

import tapestry.pages.ExceptionDisplayPage;
import tapestry.annotations.ExceptionDisplay;

public class ExceptionDisplayWorker implements
ComponentClassTransformWorker2
{
   private final MethodAdvice advice = new MethodAdvice()
{
  @Inject
  private PageRenderLinkSource pageRenderLinkSource;

  @Inject
  private Response response;

@Override
public void advise(MethodInvocation invocation)
{
System.out.println(this.pageRenderLinkSource + ; +
this.response); // Both null.

MethodInvocation result = invocation.proceed();

if (result.didThrowCheckedException())
{
 Exception exception =
result.getCheckedException(Exception.class);

 exception.printStackTrace();

 // Redirect to the exception page :

 result.setCheckedException(null);

 Link exceptionDisplayPage =
this.pageRenderLinkSource.createPageRenderLink(ExceptionDisplayPage.class);
// Problem here, pageRenderLinkSource is null.

 try
{

 this.response.sendRedirect(exceptionDisplayPage); // Problem here too,
response is null too.

}
catch (IOException e)
{
   e.printStackTrace();
}
}
}
};

   @Override
   public void transform(PlasticClass plasticClass,
TransformationSupport support, MutableComponentModel model)
   {
  for (PlasticMethod method :
plasticClass.getMethodsWithAnnotation(ExceptionDisplay.class))
  {
 method.addAdvice(this.advice);
  }
   }
}


-


Re: Error in BeginRender[...]: Parameter 'translate' of component .. is bound to null. This parameter is not allowed to be null.

2014-06-18 Thread Net Dawg


Thanks, Thiago.  Resolved.  Generally, seems like this problem is caused by 
botched getter method (my case) or not using translate/null handler in 
presentation layer.
 
I got the hint from your question below and also other solutions to the 
issue of translate attribute in textfield (to render dates etc).  Turns 
out programmer had overloaded the getter method in this case.  
Specifically, the entity class, Project, had a isDetails() as well as 
getDetails() method within the entity class.  No clue why someone 
would do that.  However, this made the detail property ambiguous to the 
textfield renderer and it was looking to translate boolean which was 
actually null in the database - disaster  I just changed the 
spelling of the method from isDetails() to isDetailed() and took care of the 
cascading effects.  The whole application is working fine now.  

Other resources on this topic (just Google the Error): 
 1.  Programmers Lounge: Error: Parameter 'translate' of component is bound to 
null This parameter is not allowed to be null.
2.  java - Allow Number object to be null in Tapestry BeanEditor - Stack 
Overflow

 
 Programmers Lounge: Error: Parameter 'translate' of component is bound to null 
This parameter is ...
Error in Tapestry: An unexpected application exception has occurred.   
View on programmerslounge.blogspot.com Preview by Yahoo  
 
 
 java - Allow Number object to be null in Tapestry BeanEditor - Stack Overflow
I have an object I'd like to edit via beaneditor. One of the properties is of 
the Number class. When I try to display the beaneditor, I get the following 
error:   
View on stackoverflow.com Preview by Yahoo  
 



On Tuesday, June 17, 2014 7:32 AM, Thiago H de Paula Figueiredo 
thiag...@gmail.com wrote:
 


On Tue, 17 Jun 2014 13:55:17 -0300, Net Dawg net.d...@yahoo.com wrote:


I tried explicitly dropping the null constraint at the database level - same 
issue - for some reason the parameter is being interpreted as not allowed to be 
null...while other fields defined exactly the same way are OK...



ALTER TABLE project ALTER COLUMN details DROP NOT NULL;

Tapestry itself doesn't look at database tables for defining validation 
constraints at all.

I have been looking at the bulletin boards, stack overflow and seems like a 
known issue...

Any links to other people having the same issue?

By the way, you haven't posted the full stack trace, which is very important to 
figure out what's happening. Nor you posted the full error message from 
Tapestry. You probably didn't any answers because of that. Maybe the error is 
from another component instance and you're looking at the wrong place. The 
Parameter 'translate' of ... is bound to null error message is almost always 
related to trying to edit a non-String property with TextField or TextArea. 
That's why I'm thinking you're looking at the wrong component.

t:textArea t:id=details t:validate=maxlength=255 rows=3 cols=90 
value=entity.details  /

@Entity @Indexed
public class Project 
{
    @Id @GeneratedValue @DocumentId
 @NonVisual
    private Long id;
    @Field
    private String details=;


Questions: 1.  In text area should there be another attribute?  I tried 
nulls=default  

No. Does it have public getter and setter methods?


2.  In entity class, Should there be some type other decorator besides @Field 
(the @Parameter is not allowed to experiment with acceptNull=true)

@Field is an annotation, not a decorator. @Parameter can only be used in 
Tapestry components and mixins, and your entity class isn't either. @Field 
seems to be from Lucene or Hibernate Search and it's ignored by Tapestry itself.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br