Re: Overriding BeanBlockSource

2010-11-01 Thread Taha Hafeez
It worked...

//-
//As i had to override all, I created a generic class
//---
import org.apache.tapestry5.services.DataTypeAnalyzer;
import org.apache.tapestry5.ioc.services.PropertyAdapter;

public class GenericTypeAnalyzer implements DataTypeAnalyzer {
   private final String dataType;
   private final Class dataClass;

   public GenericTypeAnalyzer(String dataType, Class dataClass){
  this.dataType = dataType;
  this.dataClass = dataClass;
   }

   public String getType(){
  return dataType;
   }

   public Class getDataClass(){
  return dataClass;
   }

   @Override
   public String identifyDataType(PropertyAdapter propertyAdapter){
  Class propertyType = propertyAdapter.getType();
  if(dataClass.isAssignableFrom(propertyType)){
 return dataType;
  }
  return null;
   }
}


Then in AppModule I did this
public static void
contributeDataTypeAnalyzer(OrderedConfiguration
configuration){
   configuration.add(TypeConstants.TEXT_TYPE,
 new GenericTypeAnalyzer(TypeConstants.TEXT_TYPE, String.class),
"before:*");
   configuration.add(TypeConstants.NUMBER_TYPE,
 new GenericTypeAnalyzer(TypeConstants.NUMBER_TYPE,
Number.class), "before:*");
   configuration.add(TypeConstants.DATE_TYPE,
 new GenericTypeAnalyzer(TypeConstants.DATE_TYPE, String.class),
"before:*");
   configuration.add(TypeConstants.PASSWORD_TYPE,
 new GenericTypeAnalyzer(TypeConstants.PASSWORD_TYPE,
String.class), "before:*");
   configuration.add(TypeConstants.ENUM_TYPE,
 new GenericTypeAnalyzer(TypeConstants.ENUM_TYPE, Enum.class),
"before:*");
   configuration.add(TypeConstants.BOOLEAN_TYPE,
 new GenericTypeAnalyzer(TypeConstants.BOOLEAN_TYPE,
Boolean.class), "before:*");
   configuration.add(TypeConstants.CALENDAR_TYPE,
 new GenericTypeAnalyzer(TypeConstants.CALENDAR_TYPE,
Calendar.class), "before:*");
}

public static void
contributeBeanBlockSource(Configuration
configuration){
   addEditBlock(configuration, TypeConstants.TEXT_TYPE);
   addEditBlock(configuration, TypeConstants.NUMBER_TYPE);
   addEditBlock(configuration, TypeConstants.DATE_TYPE);
   addEditBlock(configuration, TypeConstants.ENUM_TYPE);
   addEditBlock(configuration, TypeConstants.BOOLEAN_TYPE);
   addEditBlock(configuration, TypeConstants.PASSWORD_TYPE);
   addEditBlock(configuration, TypeConstants.CALENDAR_TYPE);
   addEditBlock(configuration, TypeConstants.LONG_TEXT_TYPE);
}

private static void addEditBlock(Configuration
configuration, String dataType){
   configuration.add(new BeanBlockContribution(dataType,
"PropertyEditBlocksWithoutLabel", dataType.substring(1), true));
   }


Thanks a lot
Taha


On Mon, Nov 1, 2010 at 4:22 PM, Thiago H. de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Mon, 01 Nov 2010 01:33:17 -0200, Taha Hafeez 
> wrote:
>
>  I am trying to override default editing components as I want to remove the
>> labels.. but contributeBeanBlockSource() is called in a random order (at
>> times before and at times after the TapestryModules's
>> contributeBeanBlockSource()). . I used @Order("after:*") but it is still
>> random.
>>
>
> @Order is used to specify the order decorators and advised are apllied, not
> in which order the contributed objects are included. Just do what Juan
> suggested (adding a DataTypeAnalyzer before every other) and it will work.
> :)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


Re: Overriding BeanBlockSource

2010-11-01 Thread Thiago H. de Paula Figueiredo
On Mon, 01 Nov 2010 01:33:17 -0200, Taha Hafeez   
wrote:


I am trying to override default editing components as I want to remove  
the labels.. but contributeBeanBlockSource() is called in a random order  
(at

times before and at times after the TapestryModules's
contributeBeanBlockSource()). . I used @Order("after:*") but it is still
random.


@Order is used to specify the order decorators and advised are apllied,  
not in which order the contributed objects are included. Just do what Juan  
suggested (adding a DataTypeAnalyzer before every other) and it will work.  
:)


--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor

Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

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



Re: Overriding BeanBlockSource

2010-11-01 Thread Juan E. Maya
Hello Taha,

what you can do is to contribute a new DataTypeAnalyzer and then
contribute its bean block source. The DataTypeAnalyzer is a
orderedlist so you can control their order.

For example if you would like to override the date selector used by
tapestry u should have something like this in your module:

public static void
contributeDataTypeAnalyzer(OrderedConfiguration
configuration) {
   configuration.add(DateTypeAnalyzer.DATE_TYPE, new
DateTypeAnalyzer(), "before:*");
}

public void contributeBeanBlockSource(Configuration
configuration) {
configuration.add(new
BeanBlockContribution(DateTypeAnalyzer.DATE_TYPE, "BrandingBlocks",
"dateBlock", true));
}


The DateTypeAnalyzer is something like:
public class DateTypeAnalyzer implements DataTypeAnalyzer {

public static final String DATE_TYPE = "nebulaDate";

@Override
public String identifyDataType(PropertyAdapter adapter) {
Class propertyType = adapter.getType();
if (Date.class.equals(propertyType)){
return DATE_TYPE;
}

return null;
}
}

finally you define the block. for example:




  


I hope it helps :)




On Mon, Nov 1, 2010 at 4:33 AM, Taha Hafeez  wrote:
> I am trying to override default editing components as I want to remove the
> labels.. but contributeBeanBlockSource() is called in a random order (at
> times before and at times after the TapestryModules's
> contributeBeanBlockSource()). . I used @Order("after:*") but it is still
> random.
>
> Someone already had the same issue(
> http://www.mail-archive.com/users@tapestry.apache.org/msg29783.html). Has
> this been resolved or I am doing something wrong...
>
> Taha
>

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



Overriding BeanBlockSource

2010-10-31 Thread Taha Hafeez
I am trying to override default editing components as I want to remove the
labels.. but contributeBeanBlockSource() is called in a random order (at
times before and at times after the TapestryModules's
contributeBeanBlockSource()). . I used @Order("after:*") but it is still
random.

Someone already had the same issue(
http://www.mail-archive.com/users@tapestry.apache.org/msg29783.html). Has
this been resolved or I am doing something wrong...

Taha


Re: Overriding BeanBlockSource (serious issue with contributeBeanBlockSource)

2008-10-21 Thread Moritz Gmelin
I tried to add @Order("after:*") to the contributeBeanBlockSource  
method but the execution order is still random.



Am 20.10.2008 um 23:40 schrieb Moritz Gmelin:


Hi Howard,

Thanks for taking the time to answer. I understand the licensing  
thing. However the other problem seems to be more serious.


My own contributed BeanBlockSources to override the standard Date  
editor is taken into account on a random basis.


I have added some println's in TapestryModule  
contributeBeanBlockSource and in my AppModules  
contributeBeanBlockSource method.


The order in which those two methods are called is random. Sometimes  
yours is called first then mine (in which case my contributed  
DateTime Editor is used). On other application starts, my  
contributeBeanBlockSource method is called before yours. Causing my  
Custom Editor to be ignored (overriden by yours).


Here are two stack traces from within both methods that might help  
solve this serious issue


Contributing DateTimeField BeanBlockContribution in TapestryModule
java.lang.Throwable
	at  
org 
.apache 
.tapestry5 
.services 
.TapestryModule.contributeBeanBlockSource(TapestryModule.java:444)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at  
sun 
.reflect 
.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at  
sun 
.reflect 
.DelegatingMethodAccessorImpl 
.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java: 
95)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.ContributionDefImpl.contribute(ContributionDefImpl.java:56)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.RegistryImpl.addToUnorderedConfiguration(RegistryImpl.java: 
481)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.RegistryImpl.getUnorderedConfiguration(RegistryImpl.java: 
355)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ServiceResourcesImpl 
.getUnorderedConfiguration(ServiceResourcesImpl.java:72)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.AbstractServiceCreator 
.addUnorderedConfigurationParameter(AbstractServiceCreator.java:140)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.AbstractServiceCreator 
.getParameterDefaultsWithConfiguration(AbstractServiceCreator.java: 
106)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ConstructorServiceCreator 
.getParameterDefaultsWithConfigurations 
(ConstructorServiceCreator.java:72)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ConstructorServiceCreator 
.createObject(ConstructorServiceCreator.java:47)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.SingletonServiceLifecycle 
.createService(SingletonServiceLifecycle.java:29)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.LifecycleWrappedServiceCreator 
.createObject(LifecycleWrappedServiceCreator.java:52)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.RecursiveServiceCreationCheckWrapper 
.createObject(RecursiveServiceCreationCheckWrapper.java:60)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.services 
.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
	at  
$ 
BeanBlockSource_11d1c2a616c 
.delegate($BeanBlockSource_11d1c2a616c.java)
	at  
$ 
BeanBlockSource_11d1c2a616c 
.getEditBlock($BeanBlockSource_11d1c2a616c.java)
	at  
org 
.apache 
.tapestry5 
.corelib.components.PropertyEditor.beginRender(PropertyEditor.java: 
253)
	at  
org 
.apache 
.tapestry5 
.corelib.components.PropertyEditor.beginRender(PropertyEditor.java)
	at org.apache.tapestry5.internal.structure.ComponentPageElementImpl 
$11$1.run(ComponentPageElementImpl.java:347)
	at  
org 
.apache 
.tapestry5 
.internal 
.structure 
.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:912)
	at  
org 
.apache.tapestry5.internal.structure.ComponentPageElementImpl.access 
$1(ComponentPageElementImpl.java:904)
	at org.apache.tapestry5.internal.structure.ComponentPageElementImpl 
$11.render(ComponentPageElementImpl.java:351)
	at  
org 
.apache 
.tapestry5 
.internal.services.RenderQueueImpl.run(RenderQueueImpl.java:72)
	at  
org 
.apache 
.tapestry5 
.internal 
.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java:108)
	at  
$PageRenderQueue_11d1c2a618f.render($PageRenderQueue_11d1c2a618f.java)
	at  
$PageRenderQueue_11d1c2a617e.render($PageRenderQueue_11d1c2a617e.java)
	at org.apache.tapestry5.services.TapestryModule 
$19.renderMarkup(TapestryModule.java:1201)
	at org.apache.tapestry5.services.TapestryModule 
$28.renderMarkup(TapestryModule.java:1552)
	at  
$ 
MarkupRenderer_11d1c2a6191 
.renderMarkup($MarkupRenderer_11d1c2a6191.java)
	at org.apache.tapestry5.services.TapestryModule 
$27.renderMarkup(TapestryModule.java:1533)
	at  
$ 
MarkupRenderer_11d1c2a6191 
.renderMarkup($MarkupRenderer_11d1c2a6191.java)
	at org.apache.tapestry5.services.Tapestry

Re: Overriding BeanBlockSource (serious issue with contributeBeanBlockSource)

2008-10-20 Thread Moritz Gmelin

Hi Howard,

Thanks for taking the time to answer. I understand the licensing  
thing. However the other problem seems to be more serious.


My own contributed BeanBlockSources to override the standard Date  
editor is taken into account on a random basis.


I have added some println's in TapestryModule  
contributeBeanBlockSource and in my AppModules  
contributeBeanBlockSource method.


The order in which those two methods are called is random. Sometimes  
yours is called first then mine (in which case my contributed DateTime  
Editor is used). On other application starts, my  
contributeBeanBlockSource method is called before yours. Causing my  
Custom Editor to be ignored (overriden by yours).


Here are two stack traces from within both methods that might help  
solve this serious issue


Contributing DateTimeField BeanBlockContribution in TapestryModule
java.lang.Throwable
	at  
org 
.apache 
.tapestry5 
.services.TapestryModule.contributeBeanBlockSource(TapestryModule.java: 
444)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at  
sun 
.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java: 
39)
	at  
sun 
.reflect 
.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java: 
25)

at java.lang.reflect.Method.invoke(Method.java:597)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.ContributionDefImpl.invokeMethod(ContributionDefImpl.java:95)
	at  
org 
.apache 
.tapestry5 
.ioc.internal.ContributionDefImpl.contribute(ContributionDefImpl.java: 
56)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal.RegistryImpl.addToUnorderedConfiguration(RegistryImpl.java: 
481)
	at  
org 
.apache 
.tapestry5 
.ioc.internal.RegistryImpl.getUnorderedConfiguration(RegistryImpl.java: 
355)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ServiceResourcesImpl 
.getUnorderedConfiguration(ServiceResourcesImpl.java:72)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.AbstractServiceCreator 
.addUnorderedConfigurationParameter(AbstractServiceCreator.java:140)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.AbstractServiceCreator 
.getParameterDefaultsWithConfiguration(AbstractServiceCreator.java:106)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ConstructorServiceCreator 
.getParameterDefaultsWithConfigurations(ConstructorServiceCreator.java: 
72)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java: 
47)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.SingletonServiceLifecycle 
.createService(SingletonServiceLifecycle.java:29)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.LifecycleWrappedServiceCreator 
.createObject(LifecycleWrappedServiceCreator.java:52)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.InterceptorStackBuilder.createObject(InterceptorStackBuilder.java:50)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.RecursiveServiceCreationCheckWrapper 
.createObject(RecursiveServiceCreationCheckWrapper.java:60)
	at  
org 
.apache 
.tapestry5 
.ioc 
.internal 
.services 
.JustInTimeObjectCreator.createObject(JustInTimeObjectCreator.java:65)
	at  
$BeanBlockSource_11d1c2a616c.delegate($BeanBlockSource_11d1c2a616c.java)
	at  
$ 
BeanBlockSource_11d1c2a616c 
.getEditBlock($BeanBlockSource_11d1c2a616c.java)
	at  
org 
.apache 
.tapestry5 
.corelib.components.PropertyEditor.beginRender(PropertyEditor.java:253)
	at  
org 
.apache 
.tapestry5 
.corelib.components.PropertyEditor.beginRender(PropertyEditor.java)
	at org.apache.tapestry5.internal.structure.ComponentPageElementImpl 
$11$1.run(ComponentPageElementImpl.java:347)
	at  
org 
.apache 
.tapestry5 
.internal 
.structure 
.ComponentPageElementImpl.invoke(ComponentPageElementImpl.java:912)
	at  
org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access 
$1(ComponentPageElementImpl.java:904)
	at org.apache.tapestry5.internal.structure.ComponentPageElementImpl 
$11.render(ComponentPageElementImpl.java:351)
	at  
org 
.apache 
.tapestry5.internal.services.RenderQueueImpl.run(RenderQueueImpl.java: 
72)
	at  
org 
.apache 
.tapestry5 
.internal.services.PageRenderQueueImpl.render(PageRenderQueueImpl.java: 
108)
	at  
$PageRenderQueue_11d1c2a618f.render($PageRenderQueue_11d1c2a618f.java)
	at  
$PageRenderQueue_11d1c2a617e.render($PageRenderQueue_11d1c2a617e.java)
	at org.apache.tapestry5.services.TapestryModule 
$19.renderMarkup(TapestryModule.java:1201)
	at org.apache.tapestry5.services.TapestryModule 
$28.renderMarkup(TapestryModule.java:1552)
	at  
$ 
MarkupRenderer_11d1c2a6191 
.renderMarkup($MarkupRenderer_11d1c2a6191.java)
	at org.apache.tapestry5.services.TapestryModule 
$27.renderMarkup(TapestryModule.java:1533)
	at  
$ 
MarkupRenderer_11d1c2a6191 
.renderMarkup($MarkupRenderer_11d1c2a6191.java)
	at org.apache.tapestry5.services.TapestryModule 
$26.renderMarkup(TapestryModule.java:1515)
	at  
$ 
MarkupRenderer_11d1c2a6191 
.renderMarkup($MarkupRenderer_11d1c2a6191.java)
	at org.apache.tapestry5.services.TapestryModule

Re: Overriding BeanBlockSource

2008-10-17 Thread Howard Lewis Ship
On Fri, Oct 17, 2008 at 2:56 AM, Moritz Gmelin <[EMAIL PROTECTED]> wrote:
> Hi,
>
> In our application we override the default editing component for Date types
> to be the DateTimeEditor from t5-components (why is that one not the
> default. It is so much nicer?).

Licensing.  An Apache project has certain limitations in this regard;
fortunately, Tapestry is so good at late binding that you can bypass
those kinds of issues.

>
>
> AppModule.java
>public static void contributeBeanBlockSource(
>Configuration
> configuration)
>{
>
>configuration.add(new BeanBlockContribution("date",
>"AppPropertyEditBlocks", "date", true));
>
>}
>
> Now it sometimes happens that dates are still rendered with the T5_Default
> DateField editor. Re-starting the application most often solves this so that
> my contributed renderer is used again.
> Is this some kind of timing issue in T5.0.15 with the contributions?

None that I can think of.  If you look at the code, there's not any
room for variations as you describibe; a Map is created when the
BeanBlockSource is realized and then the Map is just used.  Something
else must be going on.

>
> Thanks
>
> Moritz



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Overriding BeanBlockSource

2008-10-17 Thread Moritz Gmelin

Hi,

In our application we override the default editing component for Date  
types to be the DateTimeEditor from t5-components (why is that one not  
the default. It is so much nicer?).



AppModule.java
public static void contributeBeanBlockSource(
Configuration 
configuration)
{

configuration.add(new BeanBlockContribution("date",
"AppPropertyEditBlocks", "date", true));

}

Now it sometimes happens that dates are still rendered with the  
T5_Default DateField editor. Re-starting the application most often  
solves this so that my contributed renderer is used again.

Is this some kind of timing issue in T5.0.15 with the contributions?

Thanks

Moritz