Re: render nested component

2016-03-20 Thread Qbyte Consulting
ok ignore that, bumped into some tapestry4 source

would this be the approach?

  JSONObject

spec = new JSONObject
("clientId",
clientId);

171 




172 




e.attribute
("id",
clientId);

173 




174 




spec.put
("leaf",
node.isLeaf 
());

175 




176 




if (hasChildren)

177 




{

178 




Link

expandChildren = resources
.createEventLink
("expandChildren",
node.getId 
());

179 




Link

markExpanded = resources
.createEventLink

Re: render nested component

2016-03-20 Thread Qbyte Consulting
Tree uses BaseComponent that doesn't seem to be in tapestry5?

On Fri, Mar 18, 2016 at 2:15 PM, Chris Poulsen 
wrote:

> 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 <
> qbyteconsult...@gmail.com
> > 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 jquery PageScroll

2016-03-20 Thread Robert Jakeš
Thank you for reply.

I was not aware of tests for tapestry5-jquery


> I guess that you get your code form the sample at
>
> https://github.com/got5/tapestry5-jquery/blob/master/src/test/resources/org/got5/tapestry5/jquery/pages/PageScroll.tml


I manage to get it working, but now it's trying to fetch data for every
scroll.
Is there a way how to pass restrictions to the jquery script? For example
at the bottom of the page and only for scrolling down.


2016-03-20 18:14 GMT+01:00 françois facon :

> There is some documentation from the author of this component available at
>
> https://tawus.wordpress.com/2012/11/25/scrolling-pages-tapestry5-onscrollbeyond/
>
> if you have a look at the source doc,
>
> https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/components/PageScroll.java
> you will find the following code
>
> @Parameter(value = "literal:[]")
> private Object[] context;
>
> I guess that you get your code form the sample at
>
> https://github.com/got5/tapestry5-jquery/blob/master/src/test/resources/org/got5/tapestry5/jquery/pages/PageScroll.tml
>
> Your error message
>
> java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
> (via String --> Long, Long --> Integer) failed: For input string: "[]"
> java.lang.NumberFormatExceptionFor input string: "[]"
>
> come from the default value of the parameter context you have removed from
> the template.
>
> see also https://tapestry.apache.org/component-parameters.html for more
> details about parameter binding.
>
> for questions related to tapestry5 jquery component, I suggest you to open
> an issue at https://github.com/got5/tapestry5-jquery/issues.
>
> 2016-03-15 10:13 GMT+01:00 Robert Jakeš :
>
> > I am trying to use tapestry5 jquery component PageScroll for infinite
> > scrolling.
> >
> >- tapestry5 - 5.3.8
> >- tapestry5-jquery - 3.4.2
> >
> > So far i got this:
> >
> > public class PageScrollDemo {
> > private static final int PageSize = 100;
> >
> > @Property
> > private int value;
> >
> > @OnEvent("nextPage")
> > List moreValues(int pageNumber) throws InterruptedException
> {
> > List values = new ArrayList();
> > int first = pageNumber * PageSize;
> > for(int i = 0; i < PageSize; ++i){
> > values.add(first + i);
> > }
> >
> > Thread.sleep(1000);
> > return values;
> > }}
> >
> > PageScrollDemo.tml
> >
> > BEGIN
> >  > zone='zone' pageNumber="1">
> >
> > ${value}
> > 
> >  > id='scroller'>END
> >
> > But i get this error
> >
> > java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
> > (via String --> Long, Long --> Integer) failed: For input string: "[]"
> > java.lang.NumberFormatExceptionFor input string: "[]"
> > Filter stack frames Stack trace
> >
> >
> >
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> > java.lang.Long.parseLong(Long.java:589)
> > java.lang.Long.(Long.java:965)
> >
> > As far i understand, tapestry is trying to pass parameter "[]" to the
> > method moreValues(int), which fails.
> >
> > My question is why is not passing String "1" (pageNumber), which can be
> > casted to int?
> >
> > My second question is why is even pageNumber mandatory in
> > PageScrollDemo.tml? If i remove params from moreValues(), i get this:
> >
> > trace
> >
> > Triggering event 'scroll' on PageScrollDemo:pagescroll
> >
> > org.apache.tapestry5.runtime.ComponentEventExceptionFailure writing
> > parameter 'pageNumber' of component PageScrollDemo:pagescroll: Literal
> > values are not updateable.
> >
> > Could somebody please explain me how to use Pagescroll?
> >
>


Re: tapestry jquery PageScroll

2016-03-20 Thread françois facon
There is some documentation from the author of this component available at
https://tawus.wordpress.com/2012/11/25/scrolling-pages-tapestry5-onscrollbeyond/

if you have a look at the source doc,
https://github.com/got5/tapestry5-jquery/blob/master/src/main/java/org/got5/tapestry5/jquery/components/PageScroll.java
you will find the following code

@Parameter(value = "literal:[]")
private Object[] context;

I guess that you get your code form the sample at
https://github.com/got5/tapestry5-jquery/blob/master/src/test/resources/org/got5/tapestry5/jquery/pages/PageScroll.tml

Your error message

java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
(via String --> Long, Long --> Integer) failed: For input string: "[]"
java.lang.NumberFormatExceptionFor input string: "[]"

come from the default value of the parameter context you have removed from
the template.

see also https://tapestry.apache.org/component-parameters.html for more
details about parameter binding.

for questions related to tapestry5 jquery component, I suggest you to open
an issue at https://github.com/got5/tapestry5-jquery/issues.

2016-03-15 10:13 GMT+01:00 Robert Jakeš :

> I am trying to use tapestry5 jquery component PageScroll for infinite
> scrolling.
>
>- tapestry5 - 5.3.8
>- tapestry5-jquery - 3.4.2
>
> So far i got this:
>
> public class PageScrollDemo {
> private static final int PageSize = 100;
>
> @Property
> private int value;
>
> @OnEvent("nextPage")
> List moreValues(int pageNumber) throws InterruptedException {
> List values = new ArrayList();
> int first = pageNumber * PageSize;
> for(int i = 0; i < PageSize; ++i){
> values.add(first + i);
> }
>
> Thread.sleep(1000);
> return values;
> }}
>
> PageScrollDemo.tml
>
> BEGIN
>  zone='zone' pageNumber="1">
>
> ${value}
> 
>  id='scroller'>END
>
> But i get this error
>
> java.lang.RuntimeExceptionCoercion of [] to type java.lang.Integer
> (via String --> Long, Long --> Integer) failed: For input string: "[]"
> java.lang.NumberFormatExceptionFor input string: "[]"
> Filter stack frames Stack trace
>
>
> java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
> java.lang.Long.parseLong(Long.java:589)
> java.lang.Long.(Long.java:965)
>
> As far i understand, tapestry is trying to pass parameter "[]" to the
> method moreValues(int), which fails.
>
> My question is why is not passing String "1" (pageNumber), which can be
> casted to int?
>
> My second question is why is even pageNumber mandatory in
> PageScrollDemo.tml? If i remove params from moreValues(), i get this:
>
> trace
>
> Triggering event 'scroll' on PageScrollDemo:pagescroll
>
> org.apache.tapestry5.runtime.ComponentEventExceptionFailure writing
> parameter 'pageNumber' of component PageScrollDemo:pagescroll: Literal
> values are not updateable.
>
> Could somebody please explain me how to use Pagescroll?
>


Re: exception during bind

2016-03-20 Thread Kalle Korhonen
You have the wrong version of plastic and/or JRE. (And for the love of god,
please learn to post a proper question and include at least some context,
like versions of libraries you are using.)

Kalle



On Wed, Mar 16, 2016 at 9:19 PM, Qbyte Consulting  wrote:

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