TreeModel - get path of selected node
How can I get path of selected node. I know getRowKey will return me for example [0,1,0] , but how can I use that to get string representation [Test, Folder1, Node0]
I tried to loop thru it but the results are inccorect.
public String pickPara_action() {
// Add event code here...
setCurrentParagraphNumberFromRow();
return null;
private void setCurrentParagraphNumberFromRow() {
FacesContext ctx = FacesContext.getCurrentInstance();
//java.lang.ClassCastException: oracle.jbo.uicli.binding.JUCtrlHierNodeBinding
/*JUCtrlValueBindingRef*/JUCtrlHierNodeBinding tableRowRef =
/*(JUCtrlValueBindingRef)*/(JUCtrlHierNodeBinding)this.getParagraphTreeTable().getRowData();
try
paragraphPk = (Double)tableRowRef.getRow().getAttribute("pk");
catch (Exception ex) {
System.err.println ("backingToc: exception at get attribute"+ex);
String paragraphPk_str = paragraphPk.toString();
System.err.println("backingToc: before store");
IMS_UserSystemState.storeCurrentParagraphNumber(paragraphPk_str);
}
Similar Messages
-
JTree: How to get the currently selected node
How do I get the currently selected node in JTree?
getLastSelectedPathComponent() this method always return the last selected node and not the current one.
Thanks in advance
SachinUse
TreePath selectedPath = tree.getSelectionPath()If your tree allows multiple selections, use
TreePath [] selectedPaths = tree.getSelectionPaths() this will return an array of all selected tree paths.
Once you get the tree path, call the treePath.getLastPathComponent(). this should tell you the currently selected node.
Hope this helps
Sai Pullabhotla -
Hi,ALL
I want to return JTree selection.
As you know If use JTree object, we can use
getSelectionPaths(), and use Treepah object method
getLastPathComponent to get selected node.
What I want to do is.
My JTree Object model is DefaultMutableTreeNode
i want to use DefaultMutableTreeNode to access selected Node.
Can I do like this?
If I can, how to do it?
Thanks in advancedHi,
if you following that pdf ,
i think your not implemented the below code in DomodifyView method
if (firstTime) {
IWDTreeNodeType treeNode = (IWDTreeNodeType) view.getElement("TheNode");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "selectedElement".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onAction event. Parameter "selectedElement" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onAction. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnAction().addSourceMapping("path", "selectedElement");
/* The following line is necessary to create parameter mapping from parameter "path" to parameter "element".
Parameter "path" is of type string and contains the string representation of the tree element (its corresponding context element to be exact)
that raised the onLoadChildren event. Parameter "element" is of type IWDNodeElement (or extends it) and is defined as parameter in the event handler
that handles the onLoadChildren. The parameter mapping defined here translates the String "path" into the corresponding context element that then can
be accessed within the event handler
treeNode.mappingOfOnLoadChildren().addSourceMapping("path", "element");
please cross check once.
Thanks,
Ramesh -
How to display the path of selected node of a tree table.
Hi,
I have one use case where I have to display the path of node of tree table which is selected one.
e.g.
Suppose the tree table is like this.
Folder1(root)
->folder2
->folder3
->folder4
Now when I select this folder1 then path display should be "/folder1(root)"
when i select the folder4 then path should be "/folder1(root)/folder3/folder4"
Hope this one will help to understand my use case..
ThanksHello,
try this:
jsp page:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<f:view>
<af:document id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:tree value="#{bindings.RootNodes.treeModel}" var="node"
rowSelection="single" id="t1" expandAllEnabled="true"
rowDisclosureListener="#{Test.testDisclosureListener}"
selectionListener="#{Test.SelectionListener}">
<f:facet name="nodeStamp">
<af:panelGroupLayout id="pgl0">
<af:outputText rendered="#{empty node.Link}" value="#{node.Edesc}"
id="ot1"/>
<af:goLink rendered="#{!empty node.Link}" targetFrame="_blank" text="#{node.Edesc}" destination="#{node.Link}" id="gl1"/>
</af:panelGroupLayout>
</f:facet>
</af:tree>
<af:outputText value="#{bindings.Id.inputValue}" id="ot2"
partialTriggers="t1">
<af:convertNumber groupingUsed="false"
pattern="#{bindings.Id.format}"/>
</af:outputText>
</af:form>
</af:document>
</f:view>
</jsp:root>
code:
package testing;
import java.util.Iterator;
import java.util.List;
import model.businessObjects.view.ZamerTreeMenuViewRowImpl;
import oracle.adf.view.rich.component.rich.data.RichTree;
import oracle.jbo.Row;
import oracle.jbo.uicli.binding.JUCtrlHierBinding;
import oracle.jbo.uicli.binding.JUCtrlHierNodeBinding;
import org.apache.myfaces.trinidad.event.RowDisclosureEvent;
import org.apache.myfaces.trinidad.event.SelectionEvent;
import org.apache.myfaces.trinidad.model.CollectionModel;
import org.apache.myfaces.trinidad.model.RowKeySet;
public class Test{
public Test(){
public void testDisclosureListener(RowDisclosureEvent rowDisclosureEvent){
RichTree tree1=(RichTree)rowDisclosureEvent.getSource();
CollectionModel model = (CollectionModel)tree1.getValue();
JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)model.getWrappedData();
JUCtrlHierNodeBinding start = null;
List focus = (List)tree1.getFocusRowKey();
tree1.setRowKey(rowDisclosureEvent.getAddedSet().iterator().next());
System.out.println("testing.Test.testDisclosureListener>>"+treeBinding.getPath());
start = (JUCtrlHierNodeBinding)tree1.getRowData();
// ZamerTreeMenuViewRowImpl temp = (ZamerTreeMenuViewRowImpl)start.getRow();
JUCtrlHierNodeBinding parent=start.getParent();
String path="";
ZamerTreeMenuViewRowImpl r = (ZamerTreeMenuViewRowImpl)start.getRow();
path+="/"+r.getAdesc();
while(parent!=null){
r = (ZamerTreeMenuViewRowImpl)parent.getRow();
if(r==null){
break;
System.out.println("testing.Test.testDisclosureListener>>"+path); -
How-to get path to a node in SPRO
Hello guys,
I'm working on a tool which creates automatic dcumentation tool of changes in SPRO. All goes fine except one thing:
I need to generate a PATH to IMG ACTIVITY. I know the code of activity, I know it's HIER_GUID. What I need to get is all "parents" HIER_GUID of bottom node.
So far I got only one FM - STREE_GET_PATH_TO_NODE. It's fine but it returns only the path to 03 level in SPRO. (01 - is top, 02 - are components).
What I desperatly need is how to get a connection from 03 to 02 level.
You can simulate the FM with following values:
SEARCH_FOR_NODE-NODE_ID = 1C1B49FEC279D411AB74009027B70B8E
SEARCH_FOR_NODE-TREE_ID = 367A8DF9ACEE16E7E10000009B38F976
The result contain the highest node id 367A8DAFACEE16E7E10000009B38F976, which stands for "SAP Business Parnter" (according the table TNODEIMGT-NODE_ID).
But the fact, that "SAP Business Partner" is in "Cross-Application Components" is unreachable for me.
Do you know, how to get relevant node on level 02 ?
All hints will be rewarded.
Thank you
Regards
TomasHello guys,
I'm working on a tool which creates automatic dcumentation tool of changes in SPRO. All goes fine except one thing:
I need to generate a PATH to IMG ACTIVITY. I know the code of activity, I know it's HIER_GUID. What I need to get is all "parents" HIER_GUID of bottom node.
So far I got only one FM - STREE_GET_PATH_TO_NODE. It's fine but it returns only the path to 03 level in SPRO. (01 - is top, 02 - are components).
What I desperatly need is how to get a connection from 03 to 02 level.
You can simulate the FM with following values:
SEARCH_FOR_NODE-NODE_ID = 1C1B49FEC279D411AB74009027B70B8E
SEARCH_FOR_NODE-TREE_ID = 367A8DF9ACEE16E7E10000009B38F976
The result contain the highest node id 367A8DAFACEE16E7E10000009B38F976, which stands for "SAP Business Parnter" (according the table TNODEIMGT-NODE_ID).
But the fact, that "SAP Business Partner" is in "Cross-Application Components" is unreachable for me.
Do you know, how to get relevant node on level 02 ?
All hints will be rewarded.
Thank you
Regards
Tomas -
How to create open file dialogbox and get path of selected file?
Hi Experts!
i want to use button like browse button. so that i can select image from that and display selected image in imagebox and the path is to be display in edit text.
Thanking you
vishwajit kumarHi
Use this code , for this you must include Imports System.Windows.Forms name sapce
Private FileName As String
Public Function showOpenFileDialog() As String
Dim ShowFolderBrowserThread As Threading.Thread
Try
ShowFolderBrowserThread = New Threading.Thread(AddressOf ShowFolderBrowser)
If ShowFolderBrowserThread.ThreadState = System.Threading.ThreadState.Unstarted Then
ShowFolderBrowserThread.SetApartmentState(System.Threading.ApartmentState.STA)
ShowFolderBrowserThread.Start()
ElseIf ShowFolderBrowserThread.ThreadState = System.Threading.ThreadState.Stopped Then
ShowFolderBrowserThread.Start()
ShowFolderBrowserThread.Join()
End If
While ShowFolderBrowserThread.ThreadState = Threading.ThreadState.Running
Windows.Forms.Application.DoEvents()
End While
If FileName <> "" Then
Return FileName
End If
Catch ex As Exception
'SBO_Application.MessageBox("FileFile" & ex.Message)
MessageBox.Show(ex.ToString())
End Try
Return ""
End Function
Public Sub ShowFolderBrowser()
Dim MyProcs() As System.Diagnostics.Process
FileName = ""
Dim OpenFile As New OpenFileDialog
Try
OpenFile.Multiselect = False
OpenFile.Filter = "All files(*.CSV)|*.CSV"
Dim filterindex As Integer = 0
Try
filterindex = 0
Catch ex As Exception
End Try
OpenFile.FilterIndex = filterindex
OpenFile.RestoreDirectory = True
MyProcs = System.Diagnostics.Process.GetProcessesByName("SAP Business One")
If MyProcs.Length = 1 Then
For i As Integer = 0 To MyProcs.Length - 1
Dim MyWindow As New WindowWrapper(MyProcs(i).MainWindowHandle)
Dim ret As DialogResult = OpenFile.ShowDialog(MyWindow)
If ret = DialogResult.OK Then
FileName = OpenFile.FileName
OpenFile.Dispose()
Else
System.Windows.Forms.Application.ExitThread()
End If
Next
End If
Catch ex As Exception
'SBO_Application.StatusBar.SetText(ex.Message)
MessageBox.Show(ex.ToString())
FileName = ""
Finally
OpenFile.Dispose()
End Try
End Sub
Private Class WindowWrapper
Implements System.Windows.Forms.IWin32Window
Private _hwnd As System.IntPtr
Public Sub New(ByVal handle As System.IntPtr)
_hwnd = handle
End Sub
Private ReadOnly Property Handle() As System.IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _hwnd
End Get
End Property
End Class
on the browse button click write this
Dim oEditText As SAPbouiCOM.EditText = form.Items.Item("txtFlePath").Specific
oEditText .String = showOpenFileDialog()
for setting image to a picture box use this
Dim oPictureBox As SAPbouiCOM.PictureBox = form.Items.Item("picInfo").Specific
oPictureBox .Picture = "C:\image.png"
Regards
Arun -
JTree get selected node/object values
I wan to get all the selected nodes/objects values that I added to the JTree. How can I do this?
Thanks.TreePath[] paths = tree.getSelectedPath();
for(int i = 0; i < paths.length; i++){
TreeNode node = (TreeNode)paths.getLastPathComponent();
Object mySelectedObject = node.getUserObject();
}Some minor Errors
We have to use array paths[i] instead of paths
The correct code as used by me is
javax.swing.tree.TreePath[] paths = jTree1.getSelectionModel().getSelectionPaths();
for(int i = 0; i < paths.length; i++){
javax.swing.tree.TreeNode node = (javax.swing.tree.TreeNode)paths.getLastPathComponent();
System.out.println(((javax.swing.tree.DefaultMutableTreeNode)node).getUserObject());
CSJakharia -
Get tree selected node onPageLoad
We just turned on change persistence to keep our row selections as we traverse our taskflows and pages.
In one of our pages we have a situation where we have a tree (master) and table (table) whose data is partially based on what is selected in that tree. We use the following logic to determine what is selected in the tree to perform the query on the table.
public static JUCtrlHierNodeBinding getTreeSelectedNode(RichTree tree) {
JUCtrlHierNodeBinding node = null;
if (tree != null) {
Object oldRowKey = tree.getRowKey();
try {
RowKeySet selectedRowKeySet = tree.getSelectedRowKeys();
if (selectedRowKeySet != null) {
for (Object selectedRowKey : selectedRowKeySet) {
tree.setRowKey(selectedRowKey);
node = (JUCtrlHierNodeBinding)tree.getRowData();
break;
} finally {
tree.setRowKey(oldRowKey);
return node;
I hooked up a beforePhase listener on my jspx to call this function and get the (previously - last time user was on this page) selected row and then refresh the table based on the selected tree row's data. This seems to work, but . . . in my log I'm seeing the following error. It seems like for some reason it's trying to convert my Raw UUID to an int, I have no idea why.
<SortableModel> <_toRowIndex> Invalid rowkey:oracle.jbo.Key[B68F305BF7F5496D8A0FF99EE8F97CF0 ] type:class oracle.jbo.Key
<SortableModel> <_toRowIndex>
java.lang.ClassCastException: oracle.jbo.Key cannot be cast to java.lang.Integer
at org.apache.myfaces.trinidad.model.SortableModel._toRowIndex(SortableModel.java:341)
at org.apache.myfaces.trinidad.model.SortableModel.setRowKey(SortableModel.java:137)
at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel._setRowKey(ChildPropertyTreeModel.java:376)
at org.apache.myfaces.trinidad.model.ChildPropertyTreeModel.setRowKey(ChildPropertyTreeModel.java:178)
at org.apache.myfaces.trinidad.component.UIXCollection.setRowKey(UIXCollection.java:425)
at oracle.apps.aia.sr.common.JSFUtils.getTreeSelectedNode(JSFUtils.java:392)
So, I thought that maybe this wasn't the best way to get the selected node. So, after some research I changed the logic to be:
public static JUCtrlHierNodeBinding getTreeSelectedNode(RichTree tree) {
JUCtrlHierNodeBinding node = null;
if (tree != null) {
CollectionModel treeModel = (CollectionModel)tree.getValue();
if (treeModel != null ){
JUCtrlHierBinding treeBinding = (JUCtrlHierBinding)treeModel.getWrappedData();
if (treeBinding != null){
RowKeySet rks = tree.getSelectedRowKeys();
if (rks != null){
if (!rks.isEmpty()){
List firstSet = (List)rks.iterator().next();
node = treeBinding.findNodeByKeyPath(firstSet);
return node;
However, at the time of the beforePhase (I even tried an afterPhase listener) the tree isn't null, but the CollectionModel is null for some reason. I'm not sure where to go from here, any ideas?Hi,
if you use lazy loading (contentdelivery="lazy" then the data is queried after the tree renders. ou would need to set it to immediate to acess data suring the Preparerender phase).
Frank -
Can enybody please help me. I don't know really how to get path from xml
for example, this is xml:
<?xml version="1.0"?>
<purchase_order>
<po_items>
<item>
<name>#Name#</name>
<quantity>#number#</quantity>
</item>
</po_items>
</purchase_order>
and get out path by variebles #Name# and #number#.
In this case i need to get result:
purchase_order/po_items/item/name
and
purchase_order/po_items/item/quantityPitty you did not mention your db version.
putting together some functions from FunctX one can write
SQL> with t as (
select xmltype('<?xml version="1.0"?>
<purchase_order>
<po_items>
<item>
<name>#Name#</name>
<quantity>#number#</quantity>
</item>
</po_items>
</purchase_order>') xml from dual
select x.*
from t t,
xmltable('declare function local:index-of-node ( $nodes as node()* , $nodeToFind as node() ) as xs:integer*
for $seq in (1 to count($nodes)) return $seq[$nodes[$seq] is $nodeToFind]
declare function local:path-to-node-with-pos ( $node as node()? ) as xs:string
fn:string-join( for $ancestor in $node/ancestor-or-self::*
let $sibsOfSameName := $ancestor/../*[fn:name() = fn:name($ancestor)]
return fn:concat(fn:name($ancestor),
if (fn:count($sibsOfSameName) <= 1)
then "" else fn:concat( "[", local:index-of-node($sibsOfSameName,$ancestor),"]"))
element e {local:path-to-node-with-pos(//item/name[. = "#Name#"]), element name {//name}},
element e {local:path-to-node-with-pos(//item/quantity[. = "#number#"]), element name {//quantity}}'
passing t.xml
columns value varchar2(50) path 'name',
path varchar2(50) path 'text()'
) x
VALUE PATH
#Name# purchase_order/po_items/item/name
#number# purchase_order/po_items/item/quantity
2 rows selected. -
How to get the selected node value of a tree which is build on java code
Hi Experts,
How can i get the selected node value if I build the tree programatically.
I am using the following code in selectionListener but it is throwing error.
RichTreeTable treeTable = (RichTreeTable)getQaReasontreeTable();
CollectionModel _tableModel =
(CollectionModel)treeTable.getValue();
RowKeySet _selectedRowData = treeTable.getSelectedRowKeys();
Iterator rksIterator = _selectedRowData.iterator();
String selectedQaCode ="";
while (rksIterator.hasNext()) {
List key = (List)rksIterator.next();
JUCtrlHierBinding treeTableBinding =
(JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
JUCtrlHierNodeBinding nodeBinding =
treeTableBinding.findNodeByKeyPath(key);
String nodeStuctureDefname =
nodeBinding.getHierTypeBinding().getStructureDefName();
selectedQaCode = selectedQaCode + nodeBinding.getAttribute(0);
where I am using following link to create a tree with java code.
http://one-size-doesnt-fit-all.blogspot.com/2007/05/back-to-programming-programmatic-adf.html
Please help me in resolving this issue.
Regards
GayazHi,
you should also move
JUCtrlHierBinding treeTableBinding =
(JUCtrlHierBinding)((CollectionModel)treeTable.getValue()).getWrappedData();
out of the while loop as this is not necessary to be repeated for each key in the set
Frank -
I am having problems updating my itunes to the latest version, on each stage I am getting a message 'The feature you are trying to use in on a network resource that is unavailable.' I try to click OK it fails and I do not know an alternate path to select, please help?
I get message like below on each stage of the update, Quicktime, Safari & iTunes;
It's so annoying as until I update my iTunes account my phone won't sync.Many thanks for the screenshot. (The key to these is knowing which particular .msi file is being mentioned by the message.)
(1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
http://majorgeeks.com/download.php?det=4459
(2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
(3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
(4) In the list of programs that appears in CleanUp, select any Bonjour entries and click "Remove", as per the following screenshot:
(5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?
(Assuming that the QuickTime and Safari messages were also citing bonjour64.msi, you should also then be good to go with those installs too.) -
How could i get the selected node in the JTree
getLastSelectedPathComponent() �returns the parent node of currenr selected, so how could I get the selected node itself in the JTree
I will appretiate for any help!i think you can get by....
TreePath treePath = tree.getSelectionPath();
DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treePath.getLastPathComponent(); -
How to get UIComponent of the selected node in af:tree with drag and drop
Hi
Are there examples showing how one could get a UIComponent using DropEvent to be used with a Popup showing as a custom "context menu" at the target node ?
Right now, with dropEvent.getDropComponent, we could only get the tree.
We like to get its selected node so that the popup shows at the node level, not at the tree level.
ThanksHi Frank
Thanks for responding.
We like to show on our custom "context menu" using PopupHints (not using facet name contextmenu) with 3 commandMenuItems.
Since component id is needed by PopupHints to place this custom "context menu", we tried
RichTree dropTree = (RichTree)dropEvent.getDropComponent();
alignId = dropTree.getClientId(context);
// alignId = pt1:pt_region1:1:pt1:pc1:navTree
getClientId returns us the tree id and hence the context menu is placed next to tree.
We like to place the context menu next to a target node of the tree when dragging and dropping.
But we couldn't figure out how to get that node id.
In your suggestion,
List dropRowKey = (List) dropEvent.getDropSite();
RichTree dropComponent = (RichTree) dropEvent.getDropComponent();
dropCompoent.setRowKey(dropRowKey);
how do we then get the id of this node then ? What's the method ?
Thanks Frank -
Getting the name of selected Node in Adobe 3D PDF
Hello,
I'm trying to use the following code to get the name of the selected node for a 3D object in my PDF.
var c3d = this.getAnnots3D(this.pageNum)[0].context3D;
c3d.activated = true;
var select = c3d.scene.selectedNode.name;
I get the error
TypeError: c3d.scene.selectedNode is undefined
19:Console:Exec
undefined
I have placed my code at the folder level.
Can someone help please?The XPath expression for attribute is tag-name/@attribute-name
-
Problem with Jtree to xml tranform..how to set/get parent of a node?
Hi,
I am trying to develop xml import/export module.In import wizard, I am parsing the xml file and the display it in Jtree view using xml tree model which implements TreeModel and xml tree node.I am using jaxp api..
It is workin fine.
I got stuck with removal of selected node and save it as a new xml.
I am not able to get parent node of selected node in remove process,itz throwing null.I think i missed to define parent when i load treemodel.Plz help me out..give some ideas to do it..
thanks
-bala
Edited by: r_bala on May 9, 2008 4:44 AMthere's no way anyone can help you without seeing your code.
Maybe you are looking for
-
Using javaScript to change a field from required to not required
Hi, I have what seems like a simple question .I would like to know if it is possible to have a function call from my jsf code to a javascript function which could change a text field input from required to not required . I can do this through the ser
-
Inserting a MS SQL Server dataset with PHP
I have a Dreamweaver PHP site, but we use our corporate MS SQL Server 2005 servers for our data. How do I insert a dataset pointing to our MS SQL Server? The default dialog keeps requesting my MySQL server, which of course, I do not have.
-
Warehouse Task NOT Getting Saved, getting dump "Posting_illegal_statement"
HI All, While trying to "create + save" warehouse task for the inbound delivery (in EWM 9.1) , warehouse task numbers are getting generated but not saved. I am getting an update error saying "update was terminated for author ___" . On checking the du
-
is there a way to import iDVD motion menus into DVDSP?
-
Hi All, I am looking for installing OBIEE 11.1.1.6.0 in one of our Linux System. OS - Oracle Linux 5 (UL3+) 64 bits I would like to know the installation steps for this. Requirements ========= 1) What are all the software i need to download 2) Steps