Re: Mixup with page resolution

2014-01-31 Thread Mauricio Aldazosa
On Thu, Jan 30, 2014 at 2:35 AM, Lance Java lance.j...@googlemail.comwrote:

  but I'd also call that a very confusing naming of pages.


Granted :-), we have already changed the names. I also created a jira
issue: https://issues.apache.org/jira/browse/TAP5-2281 for it. I'll be
happy to provide a patch if a consensus is reached on how to handle this
(warning, exception, etc).

Thanks for your answers,
Mauricio


Override AssertSource

2014-01-31 Thread garz
Hi all,

i want to override the AssetSource service. I am doing it like described in 
http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html like this:

@Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(
MappedConfigurationClass, Object configuration) {
configuration.add(AssetSource.class, MyAssetSourceImpl.class);
}

But the following error occurs:
Exception constructing service 'PageSource': Error invoking method public 
org.apache.tapestry5.internal.services.PageSource 
org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
 Exception constructing service 'ComponentMessagesInvalidationEventHub': Error 
invoking method public static 
org.apache.tapestry5.services.InvalidationEventHub 
org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
 Exception constructing service 'ComponentMessagesSource': Error invoking 
service contribution method 
org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
 Resource, OrderedConfiguration): Cannot cast java.lang.Class to 
org.apache.tapestry5.services.AssetSource

What needs to be done to override the AssetSource service?

Best regards

Re: Override AssertSource

2014-01-31 Thread Dusko Jovanovski
try configuration.addInstance(AssetSource.class, MyAssetSourceImpl.class);

Here's the documentation for MappedConfiguration:
http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html


On Fri, Jan 31, 2014 at 5:05 PM, garz g...@gmx.net wrote:

 Hi all,

 i want to override the AssetSource service. I am doing it like described
 in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllike 
 this:

 @Contribute(ServiceOverride.class)
 public static void setupApplicationServiceOverrides(
 MappedConfigurationClass, Object configuration) {
 configuration.add(AssetSource.class,
 MyAssetSourceImpl.class);
 }

 But the following error occurs:
 Exception constructing service 'PageSource': Error invoking method public
 org.apache.tapestry5.internal.services.PageSource
 org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
 Exception constructing service 'ComponentMessagesInvalidationEventHub':
 Error invoking method public static
 org.apache.tapestry5.services.InvalidationEventHub
 org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
 Exception constructing service 'ComponentMessagesSource': Error invoking
 service contribution method
 org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
 Resource, OrderedConfiguration): Cannot cast java.lang.Class to
 org.apache.tapestry5.services.AssetSource

 What needs to be done to override the AssetSource service?

 Best regards


Class reloading

2014-01-31 Thread Richard Frovarp
I'm trying to do some work around the class reloading that Tapestry does 
for pages, but am having a bit of difficulty.


I'm placing annotations on my pages to build the menu. What happens is 
that I use the ComponentClassResolver to get the page names, and then 
use that to get the class name. I then use the standard class loader to 
load the class:

Thread.currentThread().getContextClassLoader().loadClass(className);

That class is then inspected to see if it has the appropriate annotation 
present


This all works wonderfully in production. The problem is when the 
annotation changes (or is added) during a development session. I have to 
stop and then start the container to get the menu to update. The page 
class reloading works, I just can't get the new annotations. I've found 
the IvalidationListener, so I know when a page class has changed.


I know my problem is that the class loader is caching the definition. Is 
there a Tapestry service to load the actual class for a page that 
handles the reloading? Is there a Tapestry service or class loader that 
would handle this for me?


Thanks,
Richard

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



Re: Override AssertSource

2014-01-31 Thread garz
With addInstance the exception is:

java.lang.IllegalStateException: Construction of service 'ServiceOverride' has 
failed due to recursion: the service depends on itself in some way. Please 
check org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at 
ServiceOverrideImpl.java:31) via 
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at 
TapestryIOCModule.java:49) for references to another service that is itself 
dependent on service 'ServiceOverride'.

On 31.01.2014, at 17:25, Dusko Jovanovski dusk...@gmail.com wrote:

 try configuration.addInstance(AssetSource.class, MyAssetSourceImpl.class);
 
 Here's the documentation for MappedConfiguration:
 http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html
 
 
 On Fri, Jan 31, 2014 at 5:05 PM, garz g...@gmx.net wrote:
 
 Hi all,
 
 i want to override the AssetSource service. I am doing it like described
 in http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllike 
 this:
 
@Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(
MappedConfigurationClass, Object configuration) {
configuration.add(AssetSource.class,
 MyAssetSourceImpl.class);
}
 
 But the following error occurs:
 Exception constructing service 'PageSource': Error invoking method public
 org.apache.tapestry5.internal.services.PageSource
 org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
 Exception constructing service 'ComponentMessagesInvalidationEventHub':
 Error invoking method public static
 org.apache.tapestry5.services.InvalidationEventHub
 org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
 Exception constructing service 'ComponentMessagesSource': Error invoking
 service contribution method
 org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
 Resource, OrderedConfiguration): Cannot cast java.lang.Class to
 org.apache.tapestry5.services.AssetSource
 
 What needs to be done to override the AssetSource service?
 
 Best regards



Re: Override AssertSource

2014-01-31 Thread Dimitris Zenios
Create the assetSource inside bind method
then inject it inside the contributeSerrviceOverride and instead of
addInstance use plain add



On Fri, Jan 31, 2014 at 7:43 PM, garz g...@gmx.net wrote:

 With addInstance the exception is:

 java.lang.IllegalStateException: Construction of service 'ServiceOverride'
 has failed due to recursion: the service depends on itself in some way.
 Please check
 org.apache.tapestry5.ioc.internal.services.ServiceOverrideImpl(Map) (at
 ServiceOverrideImpl.java:31) via
 org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
 TapestryIOCModule.java:49) for references to another service that is itself
 dependent on service 'ServiceOverride'.

 On 31.01.2014, at 17:25, Dusko Jovanovski dusk...@gmail.com wrote:

  try configuration.addInstance(AssetSource.class,
 MyAssetSourceImpl.class);
 
  Here's the documentation for MappedConfiguration:
 
 http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html
 
 
  On Fri, Jan 31, 2014 at 5:05 PM, garz g...@gmx.net wrote:
 
  Hi all,
 
  i want to override the AssetSource service. I am doing it like described
  in
 http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.htmllikethis:
 
 @Contribute(ServiceOverride.class)
 public static void setupApplicationServiceOverrides(
 MappedConfigurationClass, Object
 configuration) {
 configuration.add(AssetSource.class,
  MyAssetSourceImpl.class);
 }
 
  But the following error occurs:
  Exception constructing service 'PageSource': Error invoking method
 public
  org.apache.tapestry5.internal.services.PageSource
 
 org.apache.tapestry5.internal.services.InternalModule.buildPageSource(org.apache.tapestry5.internal.services.PageSourceImpl,org.apache.tapestry5.services.InvalidationEventHub,org.apache.tapestry5.services.InvalidationEventHub):
  Exception constructing service 'ComponentMessagesInvalidationEventHub':
  Error invoking method public static
  org.apache.tapestry5.services.InvalidationEventHub
 
 org.apache.tapestry5.services.TapestryModule.buildComponentMessagesInvalidationEventHub(org.apache.tapestry5.services.messages.ComponentMessagesSource):
  Exception constructing service 'ComponentMessagesSource': Error invoking
  service contribution method
 
 org.apache.tapestry5.services.TapestryModule.contributeComponentMessagesSource(AssetSource,
  Resource, OrderedConfiguration): Cannot cast java.lang.Class to
  org.apache.tapestry5.services.AssetSource
 
  What needs to be done to override the AssetSource service?
 
  Best regards




Re: Class reloading

2014-01-31 Thread Thiago H de Paula Figueiredo
On Fri, 31 Jan 2014 15:23:03 -0200, Richard Frovarp rfrov...@apache.org  
wrote:


I'm placing annotations on my pages to build the menu. What happens is  
that I use the ComponentClassResolver to get the page names, and then  
use that to get the class name. I then use the standard class loader to  
load the class:

Thread.currentThread().getContextClassLoader().loadClass(className);


Have you tried to use ComponentSource.getPage() to get the page instance  
and use getClass() to get the class instance? The way you're doing it,  
you're getting the annotations from the non-transformed class.


--
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: Override AssertSource

2014-01-31 Thread Thiago H de Paula Figueiredo
On Fri, 31 Jan 2014 16:29:28 -0200, Dimitris Zenios  
dimitris.zen...@gmail.com wrote:



Create the assetSource inside bind method
then inject it inside the contributeSerrviceOverride and instead of
addInstance use plain add


Or just decorate the service instead of overriding it. The result is the  
same, but you avoid the service recursion problems:


public static void decorateAssetSource(AssetSource originalAssetSource,  
ObjectLocator locator) {

return locator.autobuild(MyAssetSourceImpl.class);
}

Or use service advice instead of overriding or decorating it.

What exactly do you want to do, Garz?

--
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



Tapestry 4: form with dynamic checkboxes

2014-01-31 Thread Ryan
Hoping I can still get some help with Tapestry 4 on this mailing list - I
know its old but unfortunately I'm stuck with it and cannot upgrade at this
time.

I've got a form containing a table with two columns. The table is
constructed using contrib:TableView and the source paramter is a
MapString,Object. This map is dynamically created each time the page
renders and contains three keys:

- id (int)
- name (string)
- checked (boolean)

Here is the form:

form jwcid=addRegion@Form
span jwcid=@Hidden value=ognl:id/
span jwcid=@Hidden value=ognl:name/
table class=form
tr
thName/th
tdinput jwcid=@TextField displayName=Name
value=ognl:newRegion.name size=40//td
/tr
tr
td/td
td align=right
input type=submit jwcid=add@Submit label=Add
Region class=button listener=listener:doAdd parameters=ognl:{id,name
}/
/td
/tr
/table
table jwcid=sitesTable@contrib:TableView pageSize=25
width=100% class=header source=ognl:availableSites columns=Site
Name:description
tr
td jwcid=@contrib:TableColumns class=header/
/tr
tr jwcid=@contrib:TableRows row=ognl:site
class=ognl:beans.evenOdd.next
td jwcid=@contrib:TableValues align=left
class=cute/
td align=left
input type=checkbox jwcid=@Checkbox
id=ognl:'checked_' + site.id value=ognl:site.checked/
/td
/tr
/table
/form

This form and enclosed table render properly, however the part I'm stuck on
is how to determine that 'checked_id' is true. I have never been clear on
exactly how the TableRow object needs to be wired, but I have included this
method in my backing class:

public abstract MapString,Object getSite();

but neither the Map returned by this method nor the Map in 'availableSites'
has the 'checked' property set to True when I try to determine it within my
doAdd() method.

From what I understand of Tapestry4 and the form component, the checkbox
'value' is the property that is inspected on read and set on post, which
means it must map to a concrete, defined method or property. I can't do
that since I'm determining the items in the map dynamically.

What do you suggest?

Thanks,
Ryan


Re: Class reloading

2014-01-31 Thread Richard Frovarp

On 01/31/2014 12:38 PM, Thiago H de Paula Figueiredo wrote:

On Fri, 31 Jan 2014 15:23:03 -0200, Richard Frovarp
rfrov...@apache.org wrote:


I'm placing annotations on my pages to build the menu. What happens is
that I use the ComponentClassResolver to get the page names, and then
use that to get the class name. I then use the standard class loader
to load the class:
Thread.currentThread().getContextClassLoader().loadClass(className);


Have you tried to use ComponentSource.getPage() to get the page instance
and use getClass() to get the class instance? The way you're doing it,
you're getting the annotations from the non-transformed class.



I have not tried to use that service before now (didn't know it 
existed?). It is exactly what I needed to use though. Thanks for the help.


It might be useful to reference that service on the class reloading page:
http://tapestry.apache.org/class-reloading.html

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



Re: Class reloading

2014-01-31 Thread Thiago H de Paula Figueiredo
On Fri, 31 Jan 2014 17:40:47 -0200, Richard Frovarp rfrov...@apache.org  
wrote:


I have not tried to use that service before now (didn't know it  
existed?). It is exactly what I needed to use though. Thanks for the  
help.


:)


It might be useful to reference that service on the class reloading page:
http://tapestry.apache.org/class-reloading.html


Actually, the most recommended approach is to write a  
ComponentClassTransformWorker and check the annotation there, as they're  
called everytime a component (and page) class changes. You'll probably use  
MutableComponentModel.setMeta(String, String) to store the annotation  
information and later use MetaDataLocator to retrive it in a service. See,  
for example, the source of SecureWorker and RequestSecurityManagedImpl.


--
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