Hello Edward,
I did not have time to read all your code, but reading from your description
of your problem, I think I had this similar problem long time ago. The
solution to the problem with your component getting a null exception on a
parameter that was passed from (in my case) a page property is to extract
the value of the parameter using a binding function right at the beggining
of the component's rendering.
Say you have a parameter in this component like:
<parameter name="source" type="AClass" required="yes" direction="custom"/>
In your component's class implementation you will put:
AClass _source;
public abstract IBinding getSourceBinding();
public void pageDetached(org.apache.tapestry.event.PageEvent event) {
_source = null;
}
public void pageBeginRender(PageEvent event) {
_source = (AClass)getSourceBinding().getObject();
}
Now all your other components within can use the parameter by accessing the
member variable _source. I suggest also to always keep the persistent data
in the page and never in the components since you may get errors of
modifying the persistent property after it has been locked.
Hope this helped.
Richard Vong
From: Edward Scanzano <[EMAIL PROTECTED]>
Reply-To: "Tapestry users" <[email protected]>
To: tapestry-user <[email protected]>
Subject: Persistence of parameters in components part 1
Date: Thu, 21 Jul 2005 22:49:54 -0700 (PDT)
Hi all,
This topic is all the rage on the board right now so I
am hoping to finally get some resolution to it.
I have a situtation where a page passes a parameter to
a component and the component gets the variable just
fine. However when the page goes into the pool the
value of the parameter goes to null. So, as soon as
the page displays and I click on a link whose listener
depends on the parameter I get a null exception. Here
are a few java files for inspection.
Am I supposed to transfer the value from the parameter
into a persistent property in the component. If so, I
tried that and I get a
"Page recorder for page CWorkspace is locked after a
commit(), but received a change to property
currentMessage of component CWorkspace/folderList"
exception. What is the correct technique here?
Thanks
E
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE component-specification
PUBLIC "-//Apache Software Foundation//Tapestry Specification
3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<!-- generated by Spindle, http://spindle.sourceforge.net -->
<component-specification class="com.intaglio.webclient.site.CFolderList"
allow-body="yes" allow-informal-parameters="yes">
<parameter name="message"
type="com.intaglio.webclient.site.ContainerMessage" required="yes"
direction="auto"/>
<property-specification name="currentFolder"
type="com.intaglio.client.api.Folder"/>
<property-specification name="currentObject" type="java.lang.Object"/>
<property-specification name="currentRow" type="java.util.Collection"
initial-value="new Vector()"/>
<property-specification name="currentMessage"
type="com.intaglio.webclient.site.ContainerMessage" persistent="yes"/>
<context-asset name="applet_shrink" path="/images/shrink.gif"/>
<context-asset name="applet_edit" path="/images/edit.gif"/>
<context-asset name="applet_enlarge" path="/images/enlarge.gif"/>
<context-asset name="applet_minimize" path="/images/minimize.gif"/>
<context-asset name="applet_maximize" path="/images/maximize.gif"/>
<context-asset name="applet_down" path="/images/down.gif"/>
<context-asset name="applet_down2" path="/images/down2.gif"/>
<context-asset name="applet_columnspacer"
path="/images/columnspacer.jpg"/>
<context-asset name="applet_columnspacer2"
path="/images/columnspacer2.jpg"/>
<context-asset name="applet_selectedListView"
path="/images/slistview.gif"/>
<context-asset name="applet_deselectedListView"
path="/images/dlistview.gif"/>
<context-asset name="applet_selectedTreeView"
path="/images/streeview.gif"/>
<context-asset name="applet_deselectedTreeView"
path="/images/dtreeview.gif"/>
<context-asset name="applet_envelope" path="/images/envelope.jpg"/>
</component-specification>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE page-specification
PUBLIC "-//Apache Software Foundation//Tapestry Specification
3.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
<!-- generated by Spindle, http://spindle.sourceforge.net -->
<page-specification class="com.intaglio.webclient.site.CWorkspace">
<component id="pageStructure" type="CPageStructure1"/>
<property-specification name="position1Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position2Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position3Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position4Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position5Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position6Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="position7Components" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<property-specification name="positionTabComponents"
type="java.util.Vector" persistent="yes" initial-value="new Vector()"/>
<property-specification name="currentPosition1Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition2Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition3Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition4Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition5Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition6Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPosition7Component"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentPositionTabComponent"
type="com.intaglio.webclient.site.ContainerMessage"/>
<property-specification name="currentWorkspace"
type="com.intaglio.client.api.Workspace" persistent="yes"/>
<property-specification name="currentObject"
type="com.intaglio.client.api.Container" persistent="yes"/>
<property-specification name="historyStack" type="java.util.Vector"
persistent="yes" initial-value="new Vector()"/>
<component id="milestoneList" type="CMilestoneList"/>
<component id="project" type="CProject"/>
<component id="issueList" type="CIssueList"/>
<component id="taskList" type="CTaskList"/>
<component id="newsList" type="CNewsList"/>
<component id="noteList" type="CNoteList"/>
<component id="documentList" type="CDocumentList"/>
<component id="schedule" type="CSchedule1"/>
<component id="inbox" type="CInbox"/>
<component id="survey" type="CSurvey"/>
<component id="folderList" type="CFolderList"/>
<component id="forum" type="CForum"/>
<component id="milestoneList2" type="CMilestoneList"/>
<component id="project2" type="CProject"/>
<component id="issueList2" type="CIssueList"/>
<component id="taskList2" type="CTaskList"/>
<component id="newsList2" type="CNewsList"/>
<component id="noteList2" type="CNoteList"/>
<component id="documentList2" type="CDocumentList"/>
<component id="schedule2" type="CSchedule1"/>
<component id="inbox2" type="CInbox"/>
<component id="survey2" type="CSurvey"/>
<component id="folderList2" type="CFolderList"/>
<component id="forum2" type="CForum"/>
<component id="milestoneList3" type="CMilestoneList"/>
<component id="project3" type="CProject"/>
<component id="issueList3" type="CIssueList"/>
<component id="taskList3" type="CTaskList"/>
<component id="newsList3" type="CNewsList"/>
<component id="noteList3" type="CNoteList"/>
<component id="documentList3" type="CDocumentList"/>
<component id="schedule3" type="CSchedule1"/>
<component id="inbox3" type="CInbox"/>
<component id="survey3" type="CSurvey"/>
<component id="folderList3" type="CFolderList"/>
<component id="forum3" type="CForum"/>
<component id="milestoneList4" type="CMilestoneList"/>
<component id="project4" type="CProject"/>
<component id="issueList4" type="CIssueList"/>
<component id="taskList4" type="CTaskList"/>
<component id="newsList4" type="CNewsList"/>
<component id="noteList4" type="CNoteList"/>
<component id="documentList4" type="CDocumentList"/>
<component id="schedule4" type="CSchedule1"/>
<component id="inbox4" type="CInbox"/>
<component id="survey4" type="CSurvey"/>
<component id="folderList4" type="CFolderList"/>
<component id="forum4" type="CForum"/>
<component id="milestoneList5" type="CMilestoneList"/>
<component id="project5" type="CProject"/>
<component id="issueList5" type="CIssueList"/>
<component id="taskList5" type="CTaskList"/>
<component id="newsList5" type="CNewsList"/>
<component id="noteList5" type="CNoteList"/>
<component id="documentList5" type="CDocumentList"/>
<component id="schedule5" type="CSchedule1"/>
<component id="inbox5" type="CInbox"/>
<component id="survey5" type="CSurvey"/>
<component id="folderList5" type="CFolderList"/>
<component id="forum5" type="CForum"/>
<component id="milestoneList6" type="CMilestoneList"/>
<component id="project6" type="CProject"/>
<component id="issueList6" type="CIssueList"/>
<component id="taskList6" type="CTaskList"/>
<component id="newsList6" type="CNewsList"/>
<component id="noteList6" type="CNoteList"/>
<component id="documentList6" type="CDocumentList"/>
<component id="schedule6" type="CSchedule1"/>
<component id="inbox6" type="CInbox"/>
<component id="survey6" type="CSurvey"/>
<component id="folderList6" type="CFolderList"/>
<component id="forum6" type="CForum"/>
<component id="milestoneList7" type="CMilestoneList"/>
<component id="project7" type="CProject"/>
<component id="issueList7" type="CIssueList"/>
<component id="taskList7" type="CTaskList"/>
<component id="newsList7" type="CNewsList"/>
<component id="noteList7" type="CNoteList"/>
<component id="documentList7" type="CDocumentList"/>
<component id="schedule7" type="CSchedule1"/>
<component id="inbox7" type="CInbox"/>
<component id="survey7" type="CSurvey"/>
<component id="folderList7" type="CFolderList"/>
<component id="forum7" type="CForum"/>
<component id="milestoneListTab" type="CMilestoneList"/>
<component id="scheduleTab" type="CSchedule1"/>
<component id="inboxTab" type="CInbox"/>
<component id="issueListTab" type="CIssueList"/>
<component id="taskListTab" type="CTaskList"/>
<component id="folderListTab" type="CFolderList"/>
<component id="forumTab" type="CForum"/>
</page-specification>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]