Mystery solved. You must implement the IKeyProvider. Once I did that, things
began to work. Here's the change to the .page file:
...
<binding name="keyProvider" expression="@
[EMAIL PROTECTED]"/>
...
John
On Apr 12, 2005 11:12 AM, John Gordon <[EMAIL PROTECTED]> wrote:
>
> Okay, I've made some modifications to my config and to the code and am no
> longer getting any tapestry exceptions. The only problem I have now is that
> nothing happens when I click the expansion icon of the root element in the
> tree. The page posts but nothing expands.
>
> I've put logging into my custom ITreeContentProvider implementation and it
> is returning true for the hasChildren() method.
>
> At least I'm not getting explosions any longer. Here's' my updated
> code/config:
>
> [ .page file]
>
> ...
> <property-specification name="currentTreeNode"
> type="com.jasf.domain.UserProject"/>
> <component id="projectTree" type="tacos:Tree">
> <binding name="contentProvider" expression="projectTreeProvider"/>
> <binding name="value" expression="currentTreeNode"/>
> </component>
> ...
>
> [ end .page file]
>
> [ begin java file]
>
> ( I removed everything in beginPageRender() and created a simple getter)
> ...
> public ITreeContentProvider getProjectTreeProvider(){
> if(provider == null){
> provider = new ProjectTreeContentProvider(getProjects());
> }
> return provider;
> }
> ...
>
> [end java file]
>
> [begin html file]
>
> <form jwcid="@Form" >
>
> <span jwcid="projectTree" >
> <span jwcid="@InsertText" value="ognl:currentTreeNode.project.projectName"
> />
> </span>
>
>
> <input jwcid="@Submit" type="submit" listener="ognl:listeners.formSubmit"
> value="Submit" label="Submit"/> <input jwcid="@Submit" listener="ognl:
> listeners.goToTimeEntry" value="Cancel" label="Cancel" />
>
>
> </form>
>
> [end html file]
>
> Thanks for giving me all the help you are. I appreciate it very much.
>
>
> John
>
> On Apr 12, 2005 9:55 AM, Viktor Szathmary <[EMAIL PROTECTED]> wrote:
> >
> > hi,
> >
> > interesting :) couple of things:
> >
> > - the value binding should never be persistent.
> >
> > - if you do supply the "state" parameter to the tree, you'll want to
> > make sure that the corresponding property in the page is
> > persistent="yes" and you have an initial-value.
> >
> > for example, i'm using the following (in a component that's nested in
> > a page - but that shouldn't really matter):
> >
> > ...
> > <property-specification name="treeState" type="java.util.Set"
> > persistent="yes" initial-value="new java.util.HashSet()"/>
> > ...
> > <component id="tree" type="tacos:Tree">
> > <binding name="state" expression="treeState"/>
> > <binding name="contentProvider" expression="contentProvider"/>
> > <binding name="keyProvider"
> > expression="@
> > [EMAIL PROTECTED]"/>
> > <inherited-binding name="value" parameter-name="node"/>
> > <binding name="sorter" expression="sorter"/>
> > </component>
> > ...
> >
> > here the .java has a getContentProvider() that is dynamic... the
> > FileSystemTree example is also reasonably close to what you're trying
> > to do... if the problem persist, please send me the full
> > stacktrace/error page, so i can tell which property is causing this...
> > but basically, the Tree does *not* set persistent properties at all if
> > you supply a state parameter with a HashSet, so perhaps the issue is
> > somewhere else...
> >
> > viktor
> >
> >
> > On Apr 12, 2005 12:37 PM, John Gordon <[EMAIL PROTECTED]> wrote:
> > > Hey, Viktor,
> > >
> > > I downloaded the head version of tacos from cvs and built it, but am
> > still
> > > getting the commit() error. I've tried various configurations for the
> > > property-specifications, persistent="yes"; persistent="no", but with
> > no
> > > success. The results of trying your ideas follow:
> > >
> > > 1) no state param supplied: failed if I made the value binding
> > persistent
> > > (commit() error). If I made the value binding not persistent, the page
> > would
> > > render, but then I'd get a null error when clicking on an expand icon.
> > >
> > > 2) I've pretty much been doing this option from the get go. As soon as
> > I
> > > turn persistence on, I get the commit() error.
> > >
> > > 3) I'm not 100% sure what you mean by "supplied by page", but I did
> > set
> > > persistence on, but got the commit() error again. setting the
> > initial-value
> > > of the state map to anything other than HashSet causes a class cast
> > > exception.
> > >
> > > Here's my code:
> > >
> > > [the .page file: ]
> > >
> > > ...
> > > <property-specification name="projectTreeProvider"
> > > type="net.sf.tacos.model.ITreeContentProvider"/>
> > > <property-specification name="treeState"
> > > persistent="yes"
> > > type="java.util.HashSet"
> > > initial-value="new java.util.HashSet()"/>
> > > <property-specification name="currentTreeNode"
> > > type="com.jasf.domain.UserProject"
> > > persistent="yes"/>
> > > <component id="projectTree" type="tacos:Tree">
> > > <binding name="contentProvider" expression="projectTreeProvider"/>
> > > <binding name="state" expression="treeState"/>
> > > <binding name="value" expression="currentTreeNode"/>
> > > </component>
> > >
> > > [end .page file]
> > >
> > > [the java file]
> > >
> > > ...
> > > public abstract ITreeContentProvider getProjectTreeProvider();
> > > public abstract void setProjectTreeProvider(ITreeContentProvider
> > provider);
> > > ....
> > > /* (non-Javadoc)
> > > * @see org.apache.tapestry.IPage#beginPageRender()
> > > */
> > > public void pageBeginRender(PageEvent event) {
> > >
> > > setProjectTreeProvider(new ProjectTreeContentProvider(getProjects()));
> > >
> > > }
> > >
> > > ...
> > > /**
> > > * Returns a user's projects.
> > > * @return
> > > */
> > > public List getProjects() {
> > >
> > > User user = ((Visit)getVisit()).getUser(getRequestCycle());
> > >
> > > List userProjects = getTimeService().getRootUserProjects(user);
> > >
> > > log.debug("Found " + userProjects.size() + " projects for user " +
> > > user.getUserId() );
> > >
> > > return userProjects;
> > > }
> > > ...
> > >
> > > [end java file]
> > >
> > > [the html page]
> > >
> > > <form jwcid="@Form" >
> > >
> > > <span jwcid="projectTree" >
> > > <span jwcid="@InsertText" value="ognl:
> > currentTreeNode.project.projectName"
> > > />
> > > </span>
> > > <span jwcid="[EMAIL PROTECTED]" source="ognl:projects"
> > > value="ognl:project" >
> > > <span jwcid="@ProjectBlock" project="ognl:project" />
> > > </span>
> > >
> > > <input jwcid="@Submit" type="submit" listener="ognl:
> > listeners.formSubmit"
> > > value="Submit" label="Submit"/> <input jwcid="@Submit" listener="ognl:
> > > listeners.goToTimeEntry" value="Cancel" label="Cancel" />
> > >
> > > </form>
> > >
> > > [end html page]
> > >
> > > Do you have a working example of what I'm trying to do? I'm attempting
> > to
> > > use the tree to display what objects belong to a user. The List that
> > feeds
> > > my ITreeContentProvider is always being set via a call to Hibernate
> > within
> > > the beginPageRender() method.
> > >
> > > One last question: what properties of the tacos:Tree component must be
> > > persistent in order for the tree to work?
> > >
> > > thanks for your input,
> > >
> > > John
> > >
> > >
> > > On Apr 12, 2005 5:43 AM, Viktor Szathmary <[EMAIL PROTECTED]> wrote:
> > > >
> > > > hi,
> > > >
> > > > this is probably not an issue with the contentProvider, but the
> > > > initialization sequence of the tree "state" binding. there was a
> > small
> > > > bug in the tree component regarding this: the component tried to
> > > > default a persistent binding a bit too late - this should be fixed
> > in
> > > > CVS head - try building from there. alternatively, try these
> > scenarios
> > > > (with the last release):
> > > >
> > > > 1) no state param supplied at all
> > > > 2) state supplied from page property (persistent=yes, but no
> > > > initial-value)
> > > > 3) state supplied from page (persistent=yes, initial-value="
> > > > java.util.HashMap").
> > > >
> > > > regards,
> > > > viktor
> > > >
> > > >
> > > > On Apr 12, 2005 3:21 AM, John Gordon <[EMAIL PROTECTED]> wrote:
> > > > > Hi All,
> > > > >
> > > > > I've been banging my head on this one: I keep running into the
> > following
> > > > > error in the rendering of a page when trying to use the tacos:Tree
> > > > > component:
> > > > >
> > > > > Page recorder for page [my page name] is locked after a commit()
> > > > >
> > > > > I must be getting something confused between setting persistence
> > on
> > > > abstract
> > > > > classes correctly or not fully understanding the rewind/record
> > process
> > > > > entirely. The Tacos:Tree examples are not a whole bunch of help
> > here as
> > > > they
> > > > > creat static final ITreeContenProvider fields in the page classes.
> > I'm
> > > > > dynamically generated my ITreecontentProvider with a List of
> > objects
> > > > that
> > > > > are returned from the hibernate API.
> > > > >
> > > > > All the code that creates my ITreeContentProvider is done in the
> > > > > beginPageRender() method.
> > > > >
> > > > > Does anyone have an example of using the tacos:Tree component with
> > a
> > > > > non-static ITreeContentProvider?
> > > > >
> > > > > Thanks, I really appreciate it.
> > > > >
> > > > > John
> > > > >
> > > > >
> > > >
> > >
> > > --
> > > "The present letter is a very long one, simply because I had no
> > leisure to
> > > make it shorter." -- Blaise Pascal
> > > ------------------------------------------------------------------
> > > [EMAIL PROTECTED]
> > > (m)415.515.3549
> > >
> > >
> >
>
>
>
> --
> "The present letter is a very long one, simply because I had no leisure to
> make it shorter." -- Blaise Pascal
> ------------------------------------------------------------------
> [EMAIL PROTECTED]
>
--
"The present letter is a very long one, simply because I had no leisure to
make it shorter." -- Blaise Pascal
------------------------------------------------------------------
[EMAIL PROTECTED]