Re: custom edit page not possible

2012-12-17 Thread Josh Canfield
I spent the last 45 minutes installing tynamo for the first time. It's NOT
tapestry, it's a third party extension that I have never used, and I have
no idea how many people use it.

It looks like the problem is in the tynamo documentation.

 To start customizing a page, make a copy of the appropriate default page
 files and rename according the the table above.


If you just copy the Edit class verbatim from the archetype and create your
custom editor then you have two classes with the same routing annotation.

@At(/{0}/{1}/edit)

Your custom editor is getting into the ordered list after the base editor.

They (tynamo) have provided a way to order your routes:

@At(value = /{0}/{1}/edit, order = before:edit)

If you are going to continue to use this module then I highly recommend you
download the source and figure out how it works.

Josh

On Wed, Dec 12, 2012 at 8:26 PM, Ken in Nashua kcola...@live.com wrote:

 ustom edit as it sits in my build but I cannot get the activate handler to
 execute.



RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

Well after tinkering and tinkering...

this works

public Object onActivate(String id)
{
if (beanType == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(beanType, id);

if (bean == null)
return Utils.new404(messages);
return null;
}

no annotation...



Does anyone know why ?
  

RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

This doesnt work...

public Object onActivate(Class clazz, String id)
{
if (clazz == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(clazz, id);
this.beanType =  clazz;

if (bean == null)
return Utils.new404(messages);
return null;
}

cant get a breakpoint to set here

all i did was add formal parameter Class clazz and a little usage

It is very disheartening and discouraging that at this late in these releases 
that nothing is reliable or consistent or hardened.

and I am thinking if I go commercial or commit commercial with something... 
where will i stand then?

it wuold be really nice if this framework and affiliates would settle down 
finally and let something tangible gel for once.

i come from an XWindows RD in the late eighties and I developed far more 
formidable apps with XWindows out of MIT than anything else due to it's 
reliable documentation and consistent runtime.

I dont accept the fact that open source is open source suck it up and run with 
it

i have seen companies use these frameworks and its impact on product and 
developer

And I keep asking myself... when is this going to work

just frikkin pissed
  

RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

public Object onActivate(String id)
{
if (bean == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(beanType, id);

if (bean == null)
return Utils.new404(messages);
return null;
}

so this is what i have to go with in order to run
my beanType is hardwired to a certain class within the edit page... not my cup 
of tea but I have to go with it

maybe I am just too click and go... certain things are a sealed deal and I am 
inclined to set it and forget it

I want to run...actually i want to sprint... but I am tripping all over the 
place

If I missed something in the docs please someone burn me to a beautiful char

i got no clue why this handler wont work if I add a formal parameter
  

Re: custom edit page not possible

2012-12-15 Thread Geoff Callender
I'd suggest you use a single activate event handler, with a signature like 
this:

public Object onActivate(EventContext ec)

You can see it being used in here:


http://jumpstart.doublenegative.com.au/jumpstart/together/onepagecrud/persons

Doco is here:


http://tapestry.apache.org/component-events.html#ComponentEvents-EventContext

HTH,

Geoff   

On 16/12/2012, at 4:34 PM, Ken in Nashua wrote:

 
 This doesnt work...
 
public Object onActivate(Class clazz, String id)
{
if (clazz == null)
return Utils.new404(messages);
 
this.bean = contextValueEncoder.toValue(clazz, id);
this.beanType =  clazz;
 
if (bean == null)
return Utils.new404(messages);
return null;
}
 
 cant get a breakpoint to set here
 
 all i did was add formal parameter Class clazz and a little usage
 
 It is very disheartening and discouraging that at this late in these releases 
 that nothing is reliable or consistent or hardened.
 
 and I am thinking if I go commercial or commit commercial with something... 
 where will i stand then?
 
 it wuold be really nice if this framework and affiliates would settle down 
 finally and let something tangible gel for once.
 
 i come from an XWindows RD in the late eighties and I developed far more 
 formidable apps with XWindows out of MIT than anything else due to it's 
 reliable documentation and consistent runtime.
 
 I dont accept the fact that open source is open source suck it up and run 
 with it
 
 i have seen companies use these frameworks and its impact on product and 
 developer
 
 And I keep asking myself... when is this going to work
 
 just frikkin pissed
 


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



RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

Thanks Geoff, I will cook down and give that a shot.
  

RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

Well I cannot go with what I thought I could go with... 

If I add any code to propagate logic in my page... I get different results... 
which I attribute are affecting the runtime... 

@Property(write = false)
private TynamoClassDescriptor classDescriptor;

@Property
private BeanModel beanModel;

@Inject
private BeanModelSource beanModelSource;

public Object onActivate(String id)
{
if (beanType == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(beanType, id);

if (bean == null)
return Utils.new404(messages);

beanModel = beanModelSource.createEditModel(beanType, messages);

return null;
}

So i am thinking now it is some kind of race condition whereby my onActivate 
handler doesn't get called to initialize the page to render properly.

I wish there was something I could rely on to write some reliable code.

I have already proven that I cannot incorporate a formal parameter to the above 
routine or the event handler never gets called...or I think its not getting 
called or its not getting called in time

I have already proven that if I add properties and injections as above and try 
to use them inside the handler... the handler never gets called...or I think 
its not getting called or its not getting called in time

So whats multi-threaded that could be affecting the runtime with regard to 
event handlers and page rendering?




The page errors are not worth looking at because they are artificially induced
Here is the latest page error... but it is just a byproduct of the event 
handler not being invoked in order to set things up.



An unexpected application exception has 
occurred.org.apache.tapestry5.ioc.internal.OperationExceptionException
 assembling root component of page edit/Coach: Could not convert 
'bean.firstname' into a component parameter binding: Exception 
generating conduit for expression 'bean.firstname': Class 
java.lang.Object does not contain a property (or public field) named 
'firstname'.traceConstructing instance of page class 
org.tynamo.examples.hibernatesecurity.pages.edit.CoachEditAssembling root 
component for page edit/Coachjava.lang.RuntimeExceptionException
 assembling root component of page edit/Coach: Could not convert 
'bean.firstname' into a component parameter binding: Exception 
generating conduit for expression 'bean.firstname': Class 
java.lang.Object does not contain a property (or public field) named 
'firstname'.org.apache.tapestry5.ioc.internal.util.TapestryExceptionCould
 not convert 'bean.firstname' into a component parameter binding: 
Exception generating conduit for expression 'bean.firstname': Class 
java.lang.Object does not contain a property (or public field) named 
'firstname'.locationclasspath:org/tynamo/examples/hibernatesecurity/pages/edit/CoachEdit.tml,
 line 3530 --31   
32  t:beaneditor object=bean model=beanModel33
p:firstName34t:label 
for=firstnameMy FirstName/t:label35   
t:textfield t:id=firstname value=bean.firstname/36
 /p:firstName  37  /t:beaneditor 38 
 



  

RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

if I comment out the lines of code...

My event handler gets invoked... and I stop at my breakpoint..

/*
@Property(write = false)
private TynamoClassDescriptor classDescriptor;

@Property
private BeanModel beanModel;

@Inject
private BeanModelSource beanModelSource;
*/

public Object onActivate(String id)
{
if (beanType == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(beanType, id);

if (bean == null)
return Utils.new404(messages);

//beanModel = beanModelSource.createEditModel(beanType, messages);

return null;
}

If anyone can explain this runtime behavior I would appreciate it... a way 
around it so I can code properly.

It is obvious something is wrong... either a race condition or some data/code 
segment issue.

I cannot add any code for anything... otherwise my event handler never gets 
called... or it gets blocked and called too late

Thanks in advance
  

RE: custom edit page not possible

2012-12-15 Thread Ken in Nashua

I was able to get my java running and override a property on the BeanEditor 
component

The commented out code is what prevents the event handler from being invoked... 
I dont have the answer to why though

// @OnEvent(EventConstants.ACTIVATE)
// Object activate(Class clazz, String id)

//@OnEvent(EventConstants.ACTIVATE) 
//public Object onActivate(Class clazz, String id) 
//{
  
//if (clazz == null) return Utils.new404(messages);
  
//this.bean = contextValueEncoder.toValue(clazz, id); 
//this.beanType =  clazz;
  
//if (bean == null) return Utils.new404(messages);
  
//return null;  
//}
 
/*
@Property(write = false)
private TynamoClassDescriptor classDescriptor;
*/

@Property
private BeanModel beanModel;
   
@Inject
private BeanModelSource beanModelSource;

public Object onActivate(String id)
{
if (beanType == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(beanType, id);

if (bean == null)
return Utils.new404(messages);

beanModel = beanModelSource.createEditModel(beanType, messages);

return null;
}

  

Re: custom edit page not possible

2012-12-13 Thread Thiago H de Paula Figueiredo
On Thu, 13 Dec 2012 04:59:44 -0200, Ken in Nashua kcola...@live.com  
wrote:


The problem with my webapp is it keeps going into my resources dir for  
templates instead of the webapp context dir for templates.


There has been some back and forth about this in the past and I am not  
sure what the canonical way is.


It seems components can live in the webapp context dir fine.


The recommended way now (actually, for years already) is to put all  
templates in the classpath. Howard once said he regretted his decision of  
allowing templates inside the context too.


Thiago, would you know how to configure tapestry to look in one or the  
other or both directories ? being the resources dir versus the webapp  
context dir ?


This isn't configurable. Tapestry look at both places. Just put your  
templates in the classpath, as this is the recommended way.


--
Thiago H. de Paula Figueiredo

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



RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

correction

I copied Edit.tml into a respective 
resources/org/tynamo/examples/hibernatesecurity/pages/edit/CoachEdit.tml
I copied Edit.Java into a respective 
java/org/tynamo/examples/hibernatesecurity/pages/edit/CoachEdit.java 

I

  

Re: custom edit page not possible

2012-12-12 Thread Thiago H de Paula Figueiredo
On Wed, 12 Dec 2012 14:53:17 -0200, Ken in Nashua kcola...@live.com  
wrote:




Folks,


Hi!


is there any unknown magic to creating a simple custom edit page?


Absolutely no.

I copied Edit.tml into a respective  
resources/org/tynamo/examples/hibernatesecurity/edit/CoachEdit.tml

I copied Edit.Java into a respective
java/org/tynamo/examples/hibernatesecurity/edit/CoachEdit.java

I did not copy anything to webapp dir

activate never gets called in CoachEdit.JAVA and so nothing gets setup  
properly and a slew of exceptions follow


Please always post error message and stack traces when you mention then.

If there are any other details undocumented that are required to get  
this going I would be greatful.


I have no idea what you're trying to do. Are you trying to create a  
component library? What URL are you requesting?


--
Thiago H. de Paula Figueiredo

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



RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

Well this doesnt work as designed/documented

Customized tapestry-model templates

If you don't customize anything, Tynamo uses default pages. In 
Tapestry, a component (a page is a component as well) is comprised of 
two parts: its template and a backing java class. There's a default page
 for each particular operation, such as: Add, Edit, List and Show. The 
archetype will put the Java page classes to src/main/java/groupid/pages and 
the corresponding templates to /src/main/webapp.
 The cool thing about this is that you can also customize the default 
look and feel of a page for an operation type. Most of the cases, 
however, you want to customize a page specific for a particular object.

Tynamo makes decisions about what page to display based on which kind
 of page is needed and the class of the object(s) involved. It will 
first look for a page using Add, Edit, Show or List depending on the 
kind of page needed, prefixed with the unqualified-type name of the 
object. If it can't find a specific page for a given type, it will 
instead use the default Add, Edit, Show or List page, respectively. The 
following table gives some examples of how Tynamo figures out which page
 to use:


 Operation 
 Class 
 Look for page: 
 If not found, use page: 


 Edit 
 org.tynamo.recipe.entities.Recipe 
 org.tynamo.recipe.pages.edit.RecipeEdit 
 org.tynamo.recipe.pages.Edit 


 List 
 com.foo.entities.Product 
 com.foo.pages.list.ProductList 
 com.foo.pages.List 


 Add 
 org.wwf.entities.Gazelle 
 org.wwf.pages.add.GazzelleAdd 
 org.wwf.pages.Add 




To start customizing a page, make a copy of the appropriate default 
page files and rename according the the table above. Most of the UI 
customization happens in the corresponding .tml template. Keep in mind 
that a Tapestry template is more or less just a html page with selected 
additional tags starting with t:some-tapestry-element that will 
be replaced by Tapestry components (which can be comprised of other 
templates and so forth). Read Tapestry's template guide for more comprehensive 
documentation.

The typical customization needed for edit forms is that you want to 
render something else for a specific field but you are fine with other 
defaults. Property Editor Overrides
 are exactly for that purpose, see the linked documentation for exact 
examples. If we wanted to, we could replace the Form component entirely 
and create a new form from scratch using standard Tapestry components.
activate handler is never invoked.
I will generate a new project and try again but if I dont succeed I will file a 
jira ?
Edit customization is what fails.


  

Re: custom edit page not possible

2012-12-12 Thread Thiago H de Paula Figueiredo
You should have mentioned before that you're trying to use Tynamo default  
pages. We thought it was about regular Tapestry ones, not using Tynamo, so  
your question is not about Tapestry itself, but about a Tynamo feature.  
I've never used Tynamo, unfortunately, so I can't help you here.


--
Thiago H. de Paula Figueiredo

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



RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

Can anyone add to this module to make it a custom edit ?

It is currently a custom edit as it sits in my build but I cannot get the 
activate handler to execute.

And blue in the face

@At(/{0}/{1}/edit)
public class MyDomainObjectEdit
{
@Inject
private ContextValueEncoder contextValueEncoder;

@Inject
private Messages messages;

@Inject
private PersistenceService persistenceService;

@Inject
private DescriptorService descriptorService;

@Inject
private PageRenderLinkSource pageRenderLinkSource;

@Property(write = false)
private Class beanType = MyDomainObject.class;

@Property
private Object bean;

@OnEvent(EventConstants.ACTIVATE)
Object activate(Class clazz, String id)
{

if (clazz == null)
return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(clazz, id);
this.beanType = clazz;

if (bean == null)
return Utils.new404(messages);

return null;
}

@CleanupRender
void cleanup()
{
bean = null;
beanType = null;
}

/**
 * This tells Tapestry to put type  id into the URL, making it
 * bookmarkable.
 */
@OnEvent(EventConstants.PASSIVATE)
Object[] passivate()
{
return new Object[]
{ beanType, bean };
}

@Log
@CommitAfter
@OnEvent(EventConstants.SUCCESS)
Link success()
{
persistenceService.save(bean);
return back();
}

@OnEvent(cancel)
Link back()
{
return pageRenderLinkSource.createPageRenderLinkWithContext(Show.class, 
beanType, bean);
}

public String getListAllLinkMessage()
{
return TynamoMessages.listAll(messages, beanType);
}

public String getTitle()
{
return TynamoMessages.edit(messages, beanType);
}

}

  

RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

yikes,... sorry thiago... i thought I was replying into nother group

while I got you on the line...

tynamo is the better tapestry

its the best code base on the planet and operated by the best developers in the 
world

unfortunately, it lacks finish and polish

and I am probably the only guy on the planet attempting to perform a custom 
edit page

so I look like a ding dong trying to qa this thing
at least I have an eye for the right stuff

anyway, i would encourage you to check it out. it was invented by a benevolent 
engineer named chris nelson
i cannot imagine building a web app without it's backing mirror capabilities

chris handed it over to some open sourcee's in 2006 ... i actually was a 
committer to the earlier trails version
it would be nice if his best intent was actualized 

trying to shake it out and not getting very far

thanks for trying

well maybe it is a tapestry problem...

QUESTION: is there a way to specify an additional page directory for your 
tapestry app?

My issue is the app does not know where to find the template... and all goes 
tohell
  

RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

here is the actual error

An unexpected application exception has occurred.java.lang.RuntimeExceptionPage
 edit/Coach did not generate any markup when rendered. This could be 
because its template file could not be located, or because a render 
phase method in the page prevented rendering.


java/org.tynamo.examples.hibernatesecurity.pages.edit.CoachEdit.java



resources/org.tynamo.examples.hibernatesecurity.pages.edit.CoachEdit.tml

webapp/edit/CoachEdit.tml

I tried locating the template in the two above places but it still does find it.
according to tapestry docs, it is valid to locate pages beneath the pages dir 
and other folders beneath

could a render phase method be tripping it up ?

package org.tynamo.examples.hibernatesecurity.pages.edit;


import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.Link;
import org.apache.tapestry5.annotations.CleanupRender;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.hibernate.annotations.CommitAfter;
import org.apache.tapestry5.ioc.Messages;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.ContextValueEncoder;
import org.apache.tapestry5.services.PageRenderLinkSource;
import org.tynamo.examples.hibernatesecurity.model.Coach;
import org.tynamo.examples.hibernatesecurity.pages.Show;
import org.tynamo.routing.annotations.At;
import org.tynamo.services.DescriptorService;
import org.tynamo.services.PersistenceService;
import org.tynamo.util.TynamoMessages;
import org.tynamo.util.Utils;

/**
 * Page for editing and updating objects.
 *
 * @note:
 * When extending this page for customization purposes, it's better to copy  
paste code than trying to use inheritance.
 *
 */
@At(value=/{0}/{1}/edit, order = before:Show)
public class CoachEdit
{
@Inject
private ContextValueEncoder contextValueEncoder;

@Inject
private Messages messages;

@Inject
private PersistenceService persistenceService;

@Inject
private DescriptorService descriptorService;

@Inject
private PageRenderLinkSource pageRenderLinkSource;

@Property(write = false)
private Class beanType = Coach.class;

@Property
private Object bean;

@OnEvent(EventConstants.ACTIVATE)
Object activate(Class clazz, String id)
{

if (clazz == null) return Utils.new404(messages);

this.bean = contextValueEncoder.toValue(clazz, id);
this.beanType = clazz;

if (bean == null) return Utils.new404(messages);

return null;
}

@CleanupRender
void cleanup()
{
bean = null;
beanType = null;
}

/**
 * This tells Tapestry to put type  id into the URL, making it 
bookmarkable.
 */
@OnEvent(EventConstants.PASSIVATE)
Object[] passivate()
{
return new Object[]{beanType, bean};
}

@Log
@CommitAfter
@OnEvent(EventConstants.SUCCESS)
Link success()
{
persistenceService.save(bean);
return back();
}

@OnEvent(cancel)
Link back()
{
return pageRenderLinkSource.createPageRenderLinkWithContext(Show.class, 
beanType, bean);
}

public String getListAllLinkMessage()
{
return TynamoMessages.listAll(messages, beanType);
}

public String getTitle()
{
return TynamoMessages.edit(messages, beanType);
}

}

  

RE: custom edit page not possible

2012-12-12 Thread Ken in Nashua

The problem with my webapp is it keeps going into my resources dir for 
templates instead of the webapp context dir for templates.

There has been some back and forth about this in the past and I am not sure 
what the canonical way is.

It seems components can live in the webapp context dir fine.

Thiago, would you know how to configure tapestry to look in one or the other or 
both directories ? being the resources dir versus the webapp context dir ?

Thanks