TAPESTRY-1908

2016-03-19 Thread WILBERT Romain-ext
Hello,

I disagree with the closing of this defect, because it could happen that the 
object type is defined at runtime:

-  the Property type of object parameter can be an interface
-  the object parameter can be instanciated on activation regarding 
activation context

Why just not figure the beanType from object.getClass() ?

Greets


Re: render nested component

2016-03-19 Thread Chris Poulsen
Hi,

Take a look at the Tapestry Tree component to see how recursive rendering
can be done.

-- 
Chris

On Fri, Mar 18, 2016 at 6:17 AM, Qbyte Consulting  wrote:

> I am creating a Menu component (for a ul tag) that needs to
> programmatically generate the child links.
>
> I already have a MenuItem component, but this is parameter bound to a
> template, whereas now I need to programmatically drive the parameters.
>
> I either need to be able to create the existing MenuItem objects somehow in
> the Menu component and render them, or I simply write the links out in the
> menu - however since my Menu component isn't extending AbstractLink (like
> MenuItem) I can't use writeLink().
>
> Any ideas what is the simplest approach to resolve this? Code below.
>
> John
>
>
> public class Menu {
>
> /** The text. */
> @Parameter(required = true, allowNull = false, defaultPrefix =
> BindingConstants.LITERAL)
> private String name;
>
> /** The resources. */
> @Inject
> private ComponentResources resources;
>
> /** The component source. */
> @Inject
> private ComponentSource componentSource;
>
> @Inject
> private PageRenderLinkSource linkSource;
>
> /** The messages. */
> @Inject
> private Messages messages;
>
> @Inject
> private MenuService menuService;
>
> /** The state bean. */
> @SessionState(create = false)
> private SessionStateBean stateBean;
>
> /**
>  * If provided, this is the activation context for the target page (the
>  * information will be encoded into the URL). If not provided, then the
>  * target page will provide its own activation context.
>  */
> @Parameter
> private Object[] context;
>
> /**
>  * Begin render.
>  *
>  * @param writer the writer
>  */
> void beginRender(MarkupWriter writer) {
> writer.element("ul");
> for (String pageName :
> menuService.getPageNames(MenuService.Menu.valueOf(name))) {
> renderMenuItem(pageName, writer);
> }
> }
>
> private void renderMenuItem(String page, MarkupWriter writer) {
> Link link = resources.createPageLink(page,
>resources.isBound("context"), context);
>writer.element("li");
> NO!!writeLink(writer, link);
>  writer.writeRaw(messages.get(page.toLowerCase().concat(".link")));
> writer.end();
> writer.end();
> }
>
> /**
>  * After render.
>  *
>  * @param writer the writer
>  */
> void afterRender(MarkupWriter writer) {
>writer.end();
> }
> }
>
>
> public class MenuItem extends AbstractLink {
>
> /**
>  * The logical name of the page to link to.
>  */
> @Parameter(required = true, allowNull = false, defaultPrefix =
> BindingConstants.LITERAL)
> private String page;
>
> /** The text. */
> @Parameter(required = true, allowNull = false, defaultPrefix =
> BindingConstants.LITERAL)
> private String text;
>
> /** The resources. */
> @Inject
> private ComponentResources resources;
>
> /** The component source. */
> @Inject
> private ComponentSource componentSource;
>
> /** The state bean. */
> @SessionState(create = false)
> private SessionStateBean stateBean;
>
> /**
>  * If provided, this is the activation context for the target page (the
>  * information will be encoded into the URL). If not provided, then the
>  * target page will provide its own activation context.
>  */
> @Parameter
> private Object[] context;
>
> /**
>  * Begin render.
>  *
>  * @param writer the writer
>  */
> void beginRender(MarkupWriter writer) {
> if (isDisabled())
>return;
>Link link = resources.createPageLink(page,
>resources.isBound("context"), context);
>writer.element("li");
>writeLink(writer, link);
>writer.writeRaw(text);
> }
>
> /**
>  * After render.
>  *
>  * @param writer the writer
>  */
> void afterRender(MarkupWriter writer) {
> if (isDisabled())
>return;
> writer.end();
> writer.end();
> }
> }
>


Re: Tapestry ignoring expansions in HTML comments

2016-03-19 Thread David Diaz
Thank you!

On Wed, Mar 16, 2016 at 7:35 PM, Lance Java 
wrote:

>
> http://tapestryjava.blogspot.co.uk/2013/12/tapestry-quicky-conditionalcomment.html
> On 16 Mar 2016 5:42 a.m., "David Diaz"  wrote:
>
> > Hi guys,
> >
> > I've been working at my Tapestry application for a while and I'm just
> > cleaning it up and I'm currently ensuring compatibility with Internet
> > Explorer 8+. This requires me to include IE8 specific shims/polyfills for
> > certain javascript functions it's missing.
> >
> > I'm trying to do this in my Layout.tml:
> >
> >   
> > 
> > 
> > 
> >
> > Tapestry Application
> > 
> > 
> >   
> >
> > but tapestry doesn't replace the expansion with the actual location of
> the
> > file in the generated source code...
> >
> > Is there any way to do this?
> >
> > Thanks,
> > David.
> >
>


Re: exception during bind

2016-03-19 Thread Qbyte Consulting
I added a missing dependency, still IOC problems?

--- exec-maven-plugin:1.2.1:exec (default-cli) @ ComplianceReports ---
ioc.RegistryBuilder Adding module definition for class
org.apache.tapestry5.ioc.services.TapestryIOCModule
ioc.RegistryBuilder Adding module definition for class
compliancereports.services.ComplianceReportsModule
ioc.Registry Error building service proxy for service 'RegistryStartup' (at
org.apache.tapestry5.ioc.internal.services.RegistryStartup(Logger, List)
(at RegistryStartup.java:36) via
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
TapestryIOCModule.java:49)): java.lang.IllegalArgumentException
ioc.Registry Operations trace:
ioc.Registry [ 1] Creating proxy for service RegistryStartup
Exception in thread "main"
org.apache.tapestry5.ioc.internal.OperationException: Error building
service proxy for service 'RegistryStartup' (at
org.apache.tapestry5.ioc.internal.services.RegistryStartup(Logger, List)
(at RegistryStartup.java:36) via
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
TapestryIOCModule.java:49)): java.lang.IllegalArgumentException
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.ModuleImpl.create(ModuleImpl.java:332)
at
org.apache.tapestry5.ioc.internal.ModuleImpl.access$100(ModuleImpl.java:39)
at
org.apache.tapestry5.ioc.internal.ModuleImpl$1.invoke(ModuleImpl.java:191)
at
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withWrite(ConcurrentBarrier.java:140)
at
org.apache.tapestry5.ioc.internal.ModuleImpl$2.invoke(ModuleImpl.java:207)
at
org.apache.tapestry5.ioc.internal.util.ConcurrentBarrier.withRead(ConcurrentBarrier.java:85)
at
org.apache.tapestry5.ioc.internal.ModuleImpl.findOrCreate(ModuleImpl.java:213)
at
org.apache.tapestry5.ioc.internal.ModuleImpl.getService(ModuleImpl.java:109)
at
org.apache.tapestry5.ioc.internal.RegistryImpl.getService(RegistryImpl.java:421)
at
org.apache.tapestry5.ioc.internal.RegistryImpl.performRegistryStartup(RegistryImpl.java:325)
at
org.apache.tapestry5.ioc.internal.RegistryWrapper.performRegistryStartup(RegistryWrapper.java:80)
at
org.apache.tapestry5.ioc.RegistryBuilder.buildAndStartupRegistry(RegistryBuilder.java:213)
at
org.apache.tapestry5.ioc.RegistryBuilder.buildAndStartupRegistry(RegistryBuilder.java:229)
at
compliancereports.ComplianceReportsMain.main(ComplianceReportsMain.java:26)
Caused by: java.lang.RuntimeException: Error building service proxy for
service 'RegistryStartup' (at
org.apache.tapestry5.ioc.internal.services.RegistryStartup(Logger, List)
(at RegistryStartup.java:36) via
org.apache.tapestry5.ioc.services.TapestryIOCModule.bind(ServiceBinder) (at
TapestryIOCModule.java:49)): java.lang.IllegalArgumentException
at
org.apache.tapestry5.ioc.internal.ModuleImpl$4.invoke(ModuleImpl.java:327)
at
org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
... 16 more
Caused by: java.lang.IllegalArgumentException
at
org.apache.tapestry5.internal.plastic.asm.ClassReader.(ClassReader.java:167)
at
org.apache.tapestry5.internal.plastic.asm.ClassReader.(ClassReader.java:153)
at
org.apache.tapestry5.internal.plastic.PlasticInternalUtils.convertBytecodeToClassNode(PlasticInternalUtils.java:436)
at
org.apache.tapestry5.internal.plastic.PlasticClassPool.constructClassNodeFromBytecode(PlasticClassPool.java:481)
at
org.apache.tapestry5.internal.plastic.PlasticClassPool$1.convert(PlasticClassPool.java:62)
at
org.apache.tapestry5.internal.plastic.PlasticClassPool$1.convert(PlasticClassPool.java:59)
at org.apache.tapestry5.internal.plastic.Cache.get(Cache.java:37)
at
org.apache.tapestry5.internal.plastic.PlasticClassPool.getTypeCategory(PlasticClassPool.java:562)
at
org.apache.tapestry5.internal.plastic.PlasticMethodImpl.invokeDelegateAndReturnResult(PlasticMethodImpl.java:363)
at
org.apache.tapestry5.internal.plastic.PlasticMethodImpl.access$000(PlasticMethodImpl.java:24)
at
org.apache.tapestry5.internal.plastic.PlasticMethodImpl$2.doBuild(PlasticMethodImpl.java:221)
at
org.apache.tapestry5.internal.plastic.InstructionBuilderImpl.doCallback(InstructionBuilderImpl.java:832)
at
org.apache.tapestry5.internal.plastic.PlasticMethodImpl.changeImplementation(PlasticMethodImpl.java:130)
at
org.apache.tapestry5.internal.plastic.PlasticMethodImpl.delegateTo(PlasticMethodImpl.java:203)
at
org.apache.tapestry5.ioc.internal.ModuleImpl$9.transform(ModuleImpl.java:494)
at
org.apache.tapestry5.plastic.PlasticManager.createProxy(PlasticManager.java:235)
at
org.apache.tapestry5.ioc.internal.services.PlasticProxyFactoryImpl.createProxy(PlasticProxyFactoryImpl.java:64)
at
org.apache.tapestry5.io

Re: TAPESTRY-1908

2016-03-19 Thread Kalle Korhonen
I suspect you are talking about
https://issues.apache.org/jira/browse/TAPESTRY-1908 instead of
https://issues.apache.org/jira/browse/TAP5-1908? The actively worked T5
issues are in the TAP5 namespace. The former is a *nine years* old issue
with a sample code to get it to do what you want. Furthermore, the beanType
can by all means determined at runtime, that's exactly how Tynamo's
tapestry-model (http://www.tynamo.org/tapestry-model+guide/) works.
Object.getClass() works only for the simplest cases. Quite often you want
to specify an interface as the beanType for your model.

Kalle

On Wed, Mar 16, 2016 at 8:00 AM, WILBERT Romain-ext <
romain.wilbert-...@pole-emploi.fr> wrote:

> Hello,
>
> I disagree with the closing of this defect, because it could happen that
> the object type is defined at runtime:
>
> -  the Property type of object parameter can be an interface
> -  the object parameter can be instanciated on activation
> regarding activation context
>
> Why just not figure the beanType from object.getClass() ?
>
> Greets
>


render nested component

2016-03-19 Thread Qbyte Consulting
I am creating a Menu component (for a ul tag) that needs to
programmatically generate the child links.

I already have a MenuItem component, but this is parameter bound to a
template, whereas now I need to programmatically drive the parameters.

I either need to be able to create the existing MenuItem objects somehow in
the Menu component and render them, or I simply write the links out in the
menu - however since my Menu component isn't extending AbstractLink (like
MenuItem) I can't use writeLink().

Any ideas what is the simplest approach to resolve this? Code below.

John


public class Menu {

/** The text. */
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.LITERAL)
private String name;

/** The resources. */
@Inject
private ComponentResources resources;

/** The component source. */
@Inject
private ComponentSource componentSource;

@Inject
private PageRenderLinkSource linkSource;

/** The messages. */
@Inject
private Messages messages;

@Inject
private MenuService menuService;

/** The state bean. */
@SessionState(create = false)
private SessionStateBean stateBean;

/**
 * If provided, this is the activation context for the target page (the
 * information will be encoded into the URL). If not provided, then the
 * target page will provide its own activation context.
 */
@Parameter
private Object[] context;

/**
 * Begin render.
 *
 * @param writer the writer
 */
void beginRender(MarkupWriter writer) {
writer.element("ul");
for (String pageName :
menuService.getPageNames(MenuService.Menu.valueOf(name))) {
renderMenuItem(pageName, writer);
}
}

private void renderMenuItem(String page, MarkupWriter writer) {
Link link = resources.createPageLink(page,
   resources.isBound("context"), context);
   writer.element("li");
NO!!writeLink(writer, link);
 writer.writeRaw(messages.get(page.toLowerCase().concat(".link")));
writer.end();
writer.end();
}

/**
 * After render.
 *
 * @param writer the writer
 */
void afterRender(MarkupWriter writer) {
   writer.end();
}
}


public class MenuItem extends AbstractLink {

/**
 * The logical name of the page to link to.
 */
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.LITERAL)
private String page;

/** The text. */
@Parameter(required = true, allowNull = false, defaultPrefix =
BindingConstants.LITERAL)
private String text;

/** The resources. */
@Inject
private ComponentResources resources;

/** The component source. */
@Inject
private ComponentSource componentSource;

/** The state bean. */
@SessionState(create = false)
private SessionStateBean stateBean;

/**
 * If provided, this is the activation context for the target page (the
 * information will be encoded into the URL). If not provided, then the
 * target page will provide its own activation context.
 */
@Parameter
private Object[] context;

/**
 * Begin render.
 *
 * @param writer the writer
 */
void beginRender(MarkupWriter writer) {
if (isDisabled())
   return;
   Link link = resources.createPageLink(page,
   resources.isBound("context"), context);
   writer.element("li");
   writeLink(writer, link);
   writer.writeRaw(text);
}

/**
 * After render.
 *
 * @param writer the writer
 */
void afterRender(MarkupWriter writer) {
if (isDisabled())
   return;
writer.end();
writer.end();
}
}


exception during bind

2016-03-19 Thread Qbyte Consulting
Exception in thread "main" java.lang.RuntimeException: Error invoking
service binder method
compliancereports.services.ComplianceReportsModule.bind(ServiceBinder) (at
ComplianceReportsModule.java:65): Unresolved compilation problem:

at
org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl.bind(DefaultModuleDefImpl.java:562)
at
org.apache.tapestry5.ioc.internal.DefaultModuleDefImpl.(DefaultModuleDefImpl.java:123)
at org.apache.tapestry5.ioc.RegistryBuilder.add(RegistryBuilder.java:131)
at
org.apache.tapestry5.ioc.RegistryBuilder.buildAndStartupRegistry(RegistryBuilder.java:209)
at
org.apache.tapestry5.ioc.RegistryBuilder.buildAndStartupRegistry(RegistryBuilder.java:229)
at
compliancereports.ComplianceReportsMain.main(ComplianceReportsMain.java:26)
Caused by: java.lang.Error: Unresolved compilation problem:

at
compliancereports.services.ComplianceReportsModule.bind(ComplianceReportsModule.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)