You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by "Harriett Y. Xing (HYX)" <Xi...@EBRINC.COM> on 2004/01/16 23:13:41 UTC
Invoking a pull tool method on click
Hi,
I have a pull tool $adminMenu with method toggleFolderOpen().
What I would like to do is to invoke the method whenever a user clicks on
the following link. I would like for the user to stay on the same screen
instead of being redirected to a different page.
<a href="invoking $adminMenu.toggleFolderOpen()"> Questions </a>
I know this is kind of convoluted. I am trying to implement a treeview as
the navigation menu. $adminMenu.toggleFolderOpen() updates the variable
that tracks if the folder is open or collapsed.
Is there a way to accomplish this?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: Invoking a pull tool method on click
Posted by David Demner <tu...@demner.com>.
Hi,
I don't think you can do this with a pull tool, as it doesn't really fit
with what a pull tool is. From
http://jakarta.apache.org/turbine/turbine-2.3/howto/pullmodel-howto.html:
"Java programmers can create globally accessible Java classes known as
Tools. These Tools are going to be useful for getting data out of a service
and bringing it to the presentation layer, authenticating users, or creating
links (see the TemplateLink tool that is built into Turbine). "
However, you can do it in a few other ways.
---- Solely in the velocity template (using the pull tool to get the nodes)
----
#if ($data.Parameters.ExpandQuestions == "1")
<a href="$link.setPage("TreeView.vm").addQueryData("ExpandQuestions",
"0")">Questions</a>
<!-- whatever nodes go here - probably a foreach loop that accesses your
pull tool-->
#else
<a href="$link.setPage("TreeView.vm").addQueryData("ExpandQuestions",
"1")">Questions</a>
#end
---- Using the .vm java class (if you need to process something in java)
----
* In your .vm file:
<a href="$link.setPage("TreeView.vm").addQueryData("ExpandQuestions",
1)">Questions</a>
* In a java class called TreeView.java:
public class TreeView extends SecureScreen
{
public void doBuildTemplate( RunData data, Context context )
{
super.doBuildTemplate( data, context );
if (StringUtils.equals(data.getParameters().get("ExpandQuestions"),
"1")) {
//whatever you need to get the data for the expanded tree node
//Store in List/Vector/HashMap/Array
//Put the results into context for access from the template
context.put("questionList", List/Vector/HashMap/Array);
}
}
}
---- Using an action (not really what an action is for, but it works) ----
* In your .vm file:
<a href="$link.setAction("AdminSQL").setPage("TreeView.vm")">Questions</a>
* In a java class:
public class AdminSQL extends SecureAction
{
public void doPerform(RunData data, Context context)
throws Exception
{
//whatever processing you want and store in
List/Vector/HashMap/Array
//and then put the results into context
context.put("questionList", List/Vector/HashMap/Array);
}
}
-------------------------------
The objects you add to the Context from either java class will be available
in the .vm template.
Good luck,
David
-----Original Message-----
From: Harriett Y. Xing (HYX) [mailto:Xing@EBRINC.COM]
Sent: Friday, January 16, 2004 2:14 PM
To: 'Turbine Users List'
Subject: Invoking a pull tool method on click
Hi,
I have a pull tool $adminMenu with method toggleFolderOpen().
What I would like to do is to invoke the method whenever a user clicks on
the following link. I would like for the user to stay on the same screen
instead of being redirected to a different page.
<a href="invoking $adminMenu.toggleFolderOpen()"> Questions </a>
I know this is kind of convoluted. I am trying to implement a treeview as
the navigation menu. $adminMenu.toggleFolderOpen() updates the variable
that tracks if the folder is open or collapsed.
Is there a way to accomplish this?
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org