On Sunday 12 February 2006 18:21, Izak Wessels wrote:
> Ok, let me describe my problem in a bit more detail via an analogy.
>
> Let's say I have a html table, called ComputerPartTable, in a file -
> ComputerPart. This table
> has the following columns : partID, partName,partDesc. Now the user
> can click on the partID column and that will forward them to another page,
> ComputerPartDetails, that displays the details of the selected computer
> part.
so this is a table inside some form of @For loop?
<table>
<tr jwcid="@For" source="ognl:listOfParts" value="ognl:thisPart" element="tr">
<td><a jwcid="@DirectLink" listener="listener:doShowPartDetails"
parameters="ognl:thisPart.id"><span jwcid="@Insert"
value="ognl:thisPart.id"> ...</span></a></td>
... other columns
</tr>
</table>
>
> Now, each part has different attributes. CPU has clockspeed, fsb speed,
> etc.
>
> RAM has size, speed, etc.
>
So in the java for the ComputerPart.jave
InjectPage("PartDetails")
public abstract IPage getPartDetailsPage();
public IPage doShowPartDetails (int partId) {
IPage pd = getPartDetailsPage();
pd.setPartId();
return pd;
}
> Ok, so I have created a custom component, called CPUComponentPart.jwc that
> lists the relevant details of a CPU component. But what I want to do is, I
> want to pass
> the partID to the CPUComponentPart.java so that I can lookup the correct
> details of
> the selected part.
>
> So in my ComputerPart I have
I think you are doing this backwards maybe
>
> @Parameter
> public abstract CPUComponentPart getCPUComponentPart();
where does this form action get called from, is this after the user has filled
stuff in?
>
> public void onFormAction(Integer partID) {
> getCPUComponentPart().setPartID(partID); // this is the line where i am
> getting an exception
> }
What you seem to be missing is the PartDetailsPage
public class PartDetails extends BasePage implements PageRenderListener {
public abstract void setPartId(int id):
public abstract int getPartId();
public abstract void setComponentPart (CPUComponentPart cp);
public void pageBeginRender (PageEvent event) {
if(!event.getRequestCycle().isRewinding()) {
setComponentPart(someFunctionToGetComponentFromPartID(getPartId());
....
}
and then in
PartDetails.html
<span jwcid="@ComponentPart" CPUComponentPart="ognl:componentPart" />
I've probably still totally missunderstood what you are trying to do - but
thats how I would do what you seem to be trying to do. NOTE: I tend to
avoid specification files and specify everything in-line. You can obviously
move it out to specification files if you want.
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]