Tree.isSetOpen() problems...
Ok - here's the URL where you can see this in action...
http://www.ambientdesignstlouis.com/recent.php?category=C&group=blue
If you open and close folders with the arrows, it works
perfectly. Each folder you open automatically closes the old
folder. If, however, you just click on the names of the folders,
you have to click several times to achieve the same end.
Any suggestions?
Here's the code....
It is possible to add functions directly into a jsp page. I forget what the keywords to do this are but you basically create a scriplet and tag it (somehow) as a java method. You can add all your recursive logic to the page like that. Generally, it's not very advisable to do this, but your situation may warrent it.
Similar Messages
-
I am trying to make a program that will read the tree of an xml file and later store the data in a different format...
At the moment it reads part of the tree. but then a null pointer exception occurs on the line marked (***) in the .java file attached.
It starts at the base element ('servers' in this case) then finds if it has child nodes, if so it stores them, again and again untill it finds text, it will then print the text to screen, and remove the child from the previous node. If a node no longer has any children it is removed from the list and then the next node is found...
The problem being is that is isnt correctly working, as some of the nodes in the pastNodes arraylist are being replaced by one of their child nodes....so when it comes to the point where the list gets shorter and the next node needs to be found it has an incorrect tree list in pastNodes and dies on me.
The reason for doing it like this is so that i can list the values in a tree like format in an array (eventually) such as 'servers.server.ComputerName' has value 'Bobs_PC' etc. as the program that wrote this leaves multiple smae named variables with different types of value...e.g. like 100 'Name' tags but some refer to a drive name and others to services names.
Any ideas?
Cheers for any help.
Here is my code...sorry that its so long :(
public void read(String xmlToRead){
System.out.print("\n* Reading '"+xmlToRead+"'...");
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File(xmlToRead));
// normalize text representation
doc.getDocumentElement ().normalize ();
NodeList listOfNodes = doc.getElementsByTagName("servers");
ArrayList pastNodes= new ArrayList();
pastNodes.add(listOfNodes.item(0));
while(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
System.out.println("\n------");
//stores all new nodes with children
if(((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild().getNodeName() != "#text"){
pastNodes.add(((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild());
System.out.println("NODE ADDED");
System.out.println("pastNodes Path:");
int x=0;
while(x<pastNodes.size()){
System.out.println(x+": "+((Node) pastNodes.get(x)).getNodeName());
x++;
//print the text value
Node child = ((Node) pastNodes.get(pastNodes.size()-1)).getFirstChild();
//*** NULL POINTER HERE
//System.out.println(child.getNodeName()+" / "+child.getNodeType());
if(child != null && child.getNodeName()=="#text"){System.out.println("Value: "+child.getNodeValue());}
//remove child node from parent once read
if(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
Node newNode = ((Node) pastNodes.get(pastNodes.size()-1)).removeChild(child);
pastNodes.remove(pastNodes.size()-1);
System.out.println("Child Removed: "+child.getNodeName());
pastNodes.add(newNode);
//deletes a node from list if it does not have any more children.
if(!((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes()){
System.out.println("Removed Past Node : "+(pastNodes.size()-1)+"/"+((Node) pastNodes.get(pastNodes.size()-1)).getNodeName());
pastNodes.remove(pastNodes.size()-1);
System.out.println(((Node) pastNodes.get(pastNodes.size()-1)).hasChildNodes());
}catch (SAXParseException err) {
System.out.println ("** Parsing error" + ", line " + err.getLineNumber () + ", uri " + err.getSystemId ());
System.out.println(" " + err.getMessage ());
}catch (SAXException e) {
Exception x = e.getException ();
((x == null) ? e : x).printStackTrace ();
}catch (Throwable t) {
t.printStackTrace ();
System.out.print("Done\n");
** And a snippet of the output at the consoleHere is my code...sorry that its so long :(There is no problem if the code is long. But atleast it should be formatted to help us read it.
Node child = ((Node) pastNodes.get(pastNodes.size()-
1)).getFirstChild();
//*** NULL POINTER HERE
//System.out.println(child.getNodeName()+"
deName()+" / "+child.getNodeType());I think you get the NullPointerException when you call a method on the child node. The getFirstChild() method could return null if there is no child node. It is always good to check for nulls. -
The follow Exception is threw if I put a Tree component in any page in one of my project :
java.net.MalformedURLException: no protocol: /layout/layout.dtd
stack trace:
java.net.MalformedURLException: no protocol: /layout/layout.dtd
at com.sun.rave.web.ui.renderer.template.xml.XMLLayoutDefinitionManager.getLayoutDefinition(XMLLayoutDefinitionManager.java:194) at com.sun.rave.web.ui.component.TemplateComponentBase.getLayoutDefinition(TemplateComponentBase.java:150) at com.sun.rave.web.ui.renderer.template.TemplateRenderer.encodeBegin(TemplateRenderer.java:73) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:683) at javax.faces.webapp.UIComponentTag.encodeBegin(UIComponentTag.java:591) at javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:543) at org.apache.jsp.index_jsp._jspx_meth_ui_tree_0(index_jsp.java:322) at org.apache.jsp.index_jsp._jspx_meth_ui_form_0(index_jsp.java:256) at org.apache.jsp.index_jsp._jspx_meth_ui_body_0(index_jsp.java:231) at org.apache.jsp.index_jsp._jspx_meth_ui_html_0(index_jsp.java:169) at org.apache.jsp.index_jsp._jspx_meth_ui_page_0(index_jsp.java:146) at org.apache.jsp.index_jsp._jspx_meth_f_view_0(index_jsp.java:119) at org.apache.jsp.index_jsp._jspService(index_jsp.java:89) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:105) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:336) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:297) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:247) at javax.servlet.http.HttpServlet.service(HttpServlet.java:860) at sun.reflect.GeneratedMethodAccessor183.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:517) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:723) at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:482) at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:417) at org.apache.catalina.core.ApplicationDispatcher.access$000(ApplicationDispatcher.java:80) at org.apache.catalina.core.ApplicationDispatcher$PrivilegedForward.run(ApplicationDispatcher.java:95) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:313) at com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322) at com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130) at com.sun.rave.web.ui.appbase.faces.ViewHandlerImpl.renderView(ViewHandlerImpl.java:311) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87) at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:198) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:249) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAsPrivileged(Subject.java:517) at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:282) at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:165) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:257) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:55) at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:161) at java.security.AccessController.doPrivileged(Native Method) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:263) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:225) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:173) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:132) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:551) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:933) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:189) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.doProcess(ProcessorTask.java:604) at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:475) at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:371) at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:264) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:281) at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:83)
Caused by: java.net.MalformedURLException: no protocol: /layout/layout.dtd
at java.net.URL.<init>(URL.java:567) at java.net.URL.<init>(URL.java:464) at java.net.URL.<init>(URL.java:413) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:968) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(XMLEntityManager.java:905) at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startDTDEntity(XMLEntityManager.java:872) at com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl.setInputSource(XMLDTDScannerImpl.java:282) at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(XMLDocumentScannerImpl.java:1021) at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834) at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764) at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148) at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:250) at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:292) at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:123) at com.sun.rave.web.ui.renderer.template.xml.XMLLayoutDefinitionReader.read(XMLLayoutDefinitionReader.java:146) at com.sun.rave.web.ui.renderer.template.xml.XMLLayoutDefinitionManager.getLayoutDefinition(XMLLayoutDefinitionManager.java:190) ... 82 more
Message was edited by:
hugebrush
Message was edited by:
hugebrushhello
you wrote:
>>Problem above just occurs when the application runing in bundled Sun Application Server PE 8.2 ...
How solve this problem with SAS PE8.2
I tested my app (with tree component) in Tomcat, the app not functioned normally.
I don't know, how solve this problem.
I think, it's not correctly to edit the webui.jar file.
See
http://forum.sun.com/jive/thread.jspa?forumID=123&threadID=98154
Thank you. -
I've problem with tree query where if a level > 3 the result for top level is incorrect.
Here's the query with correct result where level of depth just 3 level :
--select *from tblBOMStructed
DECLARE @BOMStructure TABLE
PartNumber varchar(14)not null ,
Descript varchar(50)not null,
Qty integer not null default 0,
Price Decimal (10,2) default 0,
TotalPrice Decimal (10,2) default 0,
ItemNumber varchar(14) not null primary key
INSERT @BOMStructure
(PartNumber ,Descript ,Qty ,Price ,ItemNumber)
VALUES ('00150060060005','BASIC TANK',1,0,'1'),
('11012142200503','SHELL',1,789.89,'1.1'),
('12052140503','TOP CONE',1,226.75,'1.2'),
('13052140503','BOTTOM CONE',1,226.75,'1.3'),
('140104116508','PIPE LEG',3,39.75,'1.4'),
('15004104','BALL FEET',3,0,'1.5'),
('1510413504','SLEEVE',1,18.03,'1.5.1'),
('1524809510','ADJUSTABLE BOLT',1,12.82,'1.5.2'),
('1530411604','BASE',1,7.27,'1.5.3')
-- Mengupdate
update @BOMStructure
set TotalPrice = 0
where PartNumber in
select PartNumber
from @BOMStructure
-- Mengisi Table Total Price
update @BOMStructure
set TotalPrice = Price * Qty;
-- Mengupdate Sub Assy Dan Main Assy di kalikan dengan qty
WITH cteParents(ItemNumber)
AS (
SELECT ItemNumber
FROM @BOMStructure
WHERE partnumber in (
select e1.PartNumber from @BOMStructure e1,@BOMStructure e2
where e2.ItemNumber > e1 .ItemNumber
and e2.ItemNumber < e1 .ItemNumber + 'Z'
and e1 .ItemNumber not like '1'
and e2 .ItemNumber Not like '1'
group by e1.PartNumber
), cteSource(ItemNumber, TotalPrice)
AS (
SELECT p.ItemNumber,
SUM(COALESCE(s.TotalPrice , 0)) AS TotalPrice
FROM cteParents AS p
LEFT JOIN (
SELECT ItemNumber AS Original,
CASE
WHEN ItemNumber LIKE '%.%' THEN ItemNumber
ELSE '1.' + ItemNumber
END AS ItemNumber,
TotalPrice = Price * Qty
FROM @BOMStructure
) AS s ON s.ItemNumber LIKE p.ItemNumber + '.%'
OR p.ItemNumber = '1'--'0'
WHERE s.Original NOT IN (SELECT ItemNumber FROM cteParents)
GROUP BY p.ItemNumber
UPDATE s
SET s.TotalPrice = q.TotalPrice * s.Qty
FROM @BOMStructure AS s
INNER JOIN cteSource AS q ON q.ItemNumber = s.ItemNumber;
--Mengupdate Harga Main Assy menggunakan function With
with cteLevel(Lvl, PartNumber, TotalPrice)
AS
select LEN (ItemNumber)- LEN(REPLACE(ItemNumber, '.', ''))as Lvl, PartNumber,TotalPrice from @BOMStructure
update s
set s.TotalPrice = (select sum(TotalPrice )from cteLevel as PriceLvl1 where Lvl = 1)
from @BOMStructure as s
INNER JOIN cteLevel AS q ON q.PartNumber = s.PartNumber
where s.ItemNumber = '1'
update @BOMStructure
set Price = TotalPrice / Qty
--Kondisi Part Number yang merupakan Sub Assembly
where PartNumber in (select e1.PartNumber from @BOMStructure e1,@BOMStructure e2
where e2.ItemNumber > e1 .ItemNumber
and e2.ItemNumber < e1 .ItemNumber + 'Z'
and e1 .ItemNumber not like '1'
and e2 .ItemNumber Not like '1'
group by e1.PartNumber )
update @BOMStructure
set Price = TotalPrice / Qty
where ItemNumber = '1'
select PartNumber, Descript , Qty , Price , TotalPrice , ItemNumber
from @BOMStructure
Here's the query with incorrect result where level of depth > 3 level :
--select *from tblBOMStructed
DECLARE @BOMStructure TABLE
PartNumber varchar(14)not null ,
Descript varchar(50)not null,
Qty integer not null default 0,
Price Decimal (10,2) default 0,
TotalPrice Decimal (10,2) default 0,
ItemNumber varchar(14) not null primary key
INSERT @BOMStructure
(PartNumber ,Descript ,Qty ,Price ,ItemNumber)
VALUES ('14300100001029','ATMOSPHERIC TANK',1,0,'1'),
('00150060060005','BASIC TANK',1,0,'1.1'),
('11012142200503','SHELL',1,789.89,'1.1.1'),
('12052140503','TOP CONE',1,226.75,'1.1.2'),
('13052140503','BOTTOM CONE',1,226.75,'1.1.3'),
('140104116508','PIPE LEG',3,39.75,'1.1.4'),
('15004104','BALL FEET',3,0,'1.1.5'),
('1510413504','SLEEVE',1,18.03,'1.1.5.1'),
('1524809510','ADJUSTABLE BOLT',1,12.82,'1.1.5.2'),
('1530411604','BASE',1,7.27,'1.1.5.3')
-- Mengupdate
update @BOMStructure
set TotalPrice = 0
where PartNumber in
select PartNumber
from @BOMStructure
-- Mengisi Table Total Price
update @BOMStructure
set TotalPrice = Price * Qty;
-- Mengupdate Sub Assy Dan Main Assy di kalikan dengan qty
WITH cteParents(ItemNumber)
AS (
SELECT ItemNumber
FROM @BOMStructure
WHERE partnumber in (
select e1.PartNumber from @BOMStructure e1,@BOMStructure e2
where e2.ItemNumber > e1 .ItemNumber
and e2.ItemNumber < e1 .ItemNumber + 'Z'
and e1 .ItemNumber not like '1'
and e2 .ItemNumber Not like '1'
group by e1.PartNumber
), cteSource(ItemNumber, TotalPrice)
AS (
SELECT p.ItemNumber,
SUM(COALESCE(s.TotalPrice , 0)) AS TotalPrice
FROM cteParents AS p
LEFT JOIN (
SELECT ItemNumber AS Original,
CASE
WHEN ItemNumber LIKE '%.%' THEN ItemNumber
ELSE '1.' + ItemNumber
END AS ItemNumber,
TotalPrice = Price * Qty
FROM @BOMStructure
) AS s ON s.ItemNumber LIKE p.ItemNumber + '.%'
OR p.ItemNumber = '1'--'0'
WHERE s.Original NOT IN (SELECT ItemNumber FROM cteParents)
GROUP BY p.ItemNumber
UPDATE s
SET s.TotalPrice = q.TotalPrice * s.Qty
FROM @BOMStructure AS s
INNER JOIN cteSource AS q ON q.ItemNumber = s.ItemNumber;
--Mengupdate Harga Main Assy menggunakan function With
with cteLevel(Lvl, PartNumber, TotalPrice)
AS
select LEN (ItemNumber)- LEN(REPLACE(ItemNumber, '.', ''))as Lvl, PartNumber,TotalPrice from @BOMStructure
update s
set s.TotalPrice = (select sum(TotalPrice )from cteLevel as PriceLvl1 where Lvl = 1)
from @BOMStructure as s
INNER JOIN cteLevel AS q ON q.PartNumber = s.PartNumber
where s.ItemNumber = '1'
update @BOMStructure
set Price = TotalPrice / Qty
--Kondisi Part Number yang merupakan Sub Assembly
where PartNumber in (select e1.PartNumber from @BOMStructure e1,@BOMStructure e2
where e2.ItemNumber > e1 .ItemNumber
and e2.ItemNumber < e1 .ItemNumber + 'Z'
and e1 .ItemNumber not like '1'
and e2 .ItemNumber Not like '1'
group by e1.PartNumber )
update @BOMStructure
set Price = TotalPrice / Qty
where ItemNumber = '1'
select PartNumber, Descript , Qty , Price , TotalPrice , ItemNumber
from @BOMStructure
Could some explain me how to solve this problem.
Regards,
Afri--select *from tblBOMStructed
DECLARE @BOMStructure TABLE (
PartNumber VARCHAR(14) NOT NULL
,Descript VARCHAR(50) NOT NULL
,Qty INTEGER NOT NULL DEFAULT 0
,Price DECIMAL(10, 2) DEFAULT 0
,TotalPrice DECIMAL(10, 2) DEFAULT 0
,ItemNumber VARCHAR(14) NOT NULL PRIMARY KEY
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'14300100001029'
,'ATMOSPHERIC TANK'
,1
,0
,'1'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'00150060060005'
,'BASIC TANK'
,1
,0
,'1.1'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'11012142200503'
,'SHELL'
,1
,789.89
,'1.1.1'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'12052140503'
,'TOP CONE'
,1
,226.75
,'1.1.2'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'13052140503'
,'BOTTOM CONE'
,1
,226.75
,'1.1.3'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'140104116508'
,'PIPE LEG'
,3
,39.75
,'1.1.4'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'15004104'
,'BALL FEET'
,3
,0
,'1.1.5'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'1510413504'
,'SLEEVE'
,1
,18.03
,'1.1.5.1'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'1524809510'
,'ADJUSTABLE BOLT'
,1
,12.82
,'1.1.5.2'
INSERT @BOMStructure (
PartNumber
,Descript
,Qty
,Price
,ItemNumber
VALUES (
'1530411604'
,'BASE'
,1
,7.27
,'1.1.5.3'
-- Mengupdate
UPDATE @BOMStructure
SET TotalPrice = 0
WHERE PartNumber IN (
SELECT PartNumber
FROM @BOMStructure
-- Mengisi Table Total Price
UPDATE @BOMStructure
SET TotalPrice = Price * Qty;
-- Mengupdate Sub Assy Dan Main Assy di kalikan dengan qty
WITH cteParents (ItemNumber)
AS (
SELECT ItemNumber
FROM @BOMStructure
WHERE partnumber IN (
SELECT e1.PartNumber
FROM @BOMStructure e1
,@BOMStructure e2
WHERE e2.ItemNumber > e1.ItemNumber
AND e2.ItemNumber < e1.ItemNumber + 'Z'
AND e1.ItemNumber NOT LIKE '1'
AND e2.ItemNumber NOT LIKE '1'
GROUP BY e1.PartNumber
,cteSource (
ItemNumber
,TotalPrice
AS (
SELECT p.ItemNumber
,SUM(COALESCE(s.TotalPrice, 0)) AS TotalPrice
FROM cteParents AS p
LEFT JOIN (
SELECT ItemNumber AS Original
,CASE
WHEN ItemNumber LIKE '%.%'
THEN ItemNumber
ELSE '1.' + ItemNumber
END AS ItemNumber
,TotalPrice = Price * Qty
FROM @BOMStructure
) AS s ON s.ItemNumber LIKE p.ItemNumber + '.%'
OR p.ItemNumber = '1' --'0'
WHERE s.Original NOT IN (
SELECT ItemNumber
FROM cteParents
GROUP BY p.ItemNumber
UPDATE s
SET s.TotalPrice = q.TotalPrice * s.Qty
FROM @BOMStructure AS s
INNER JOIN cteSource AS q ON q.ItemNumber = s.ItemNumber;
--Mengupdate Harga Main Assy menggunakan function With
WITH cteLevel (
Lvl
,PartNumber
,TotalPrice
AS (
SELECT LEN(ItemNumber) - LEN(REPLACE(ItemNumber, '.', '')) AS Lvl
,PartNumber
,TotalPrice
FROM @BOMStructure
UPDATE s
SET s.TotalPrice = (
SELECT sum(TotalPrice)
FROM cteLevel AS PriceLvl1
WHERE Lvl = 1
FROM @BOMStructure AS s
INNER JOIN cteLevel AS q ON q.PartNumber = s.PartNumber
WHERE s.ItemNumber = '1'
UPDATE @BOMStructure
SET Price = TotalPrice / Qty
--Kondisi Part Number yang merupakan Sub Assembly
WHERE PartNumber IN (
SELECT e1.PartNumber
FROM @BOMStructure e1
,@BOMStructure e2
WHERE e2.ItemNumber > e1.ItemNumber
AND e2.ItemNumber < e1.ItemNumber + 'Z'
AND e1.ItemNumber NOT LIKE '1'
AND e2.ItemNumber NOT LIKE '1'
GROUP BY e1.PartNumber
UPDATE @BOMStructure
SET Price = TotalPrice / Qty
WHERE ItemNumber = '1'
SELECT PartNumber
,Descript
,Qty
,Price
,TotalPrice
,ItemNumber
,(LEN(ItemNumber) - LEN(REPLACE(ItemNumber, '.', ''))) as C
FROM @BOMStructure
Can you explain logic behind 1 or 1.1 must 1477.00.
Shridhar J Joshi
Thanks alot -
Hierarchical tree node problem
Hi all --
Today's problem is (drum roll)............
My application uses a heirarichal tree where each tree node contains the name of a form within this system. The user can navigate from form to form by clicking the appropriatetly name tree node. This seems to work - sometimes. Some users click on a node for one form, but get transferred to another named form(usually the one above or below the one actually activated). I've also found out that this happens ONLY when the user has their screen resolution set to 800 x 600. This application was developed at screen resolution 1024 x 768 and it woks fine. Anybody know why??Here is the code for both the tree node selected and tree node activated triggers
Tree Node Seleceted code:
:CONTROL.Node_Activated := null ;
:CONTROL.Node_Selected := Ftree.Get_Tree_Node_Property('CONTROL_TREE.MENU', :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE) ;
===========================================================
Tree Node Activated code:
Declare
LN$I Pls_integer ;
Begin
:CONTROL.Node_Selected := null;
:CONTROL.Node_Activated := Ftree.Get_Tree_Node_Property('CONTROL_TREE.MENU', :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE) ;
If :CONTROL.Node_Activated IS NOT NULL Then
if :GLOBAL.curr_proc_id <> :control.node_activated or :control.node_activated
is null then
CALL_FORM(:CONTROL.Node_Activated);
else
Set_Alert_Property( 'AL_FORM_OPENED', ALERT_MESSAGE_TEXT,
:CONTROL.Node_Activated || ' is already opened. Please check your current or previously opened library.' );
LN$I := Show_Alert( 'AL_FORM_OPENED' ) ;
end if;
end if ;
end ; -
Hi all!
I'm using apex 4 and trying to use a new tree region.
My problem is that in version 3.2 I could put html tags in tree node description, but in version 4, I can't because apex translate my html tags to literal values, like this:
Select distinct c.id_funcao Id
,'0' Pid
,'teste' || c.id_funcao || ' - ' || c.ds_funcao Name
,'' Link
,'/i4/aplicabilidade1.gif' icon
From TB_AUT_FUNCAO c
In apex 4, the Name column html value is: data:{"title":"<a href=#>teste<\/a>SF_BC_ACESSO_APEX - Acesso ao Sistema Apex"...
Look at "<"... there is a way to avoid this behaviour?
Thanks.
ThiagoHi. Has anyone any idea???
Thiago -
Recursive & Loadable WD-Tree-Tutorial: Problems with parameters; NullPointe
Hello all, it's me again
This time I have a problem with the Tutorial called "Constructing a Recursive and Loadable WD-Tree". I followed each step in detail, but when I deploy it all I see several errors/mistakes in my resulting App:
1. I can click on the "directories" in this example and the directory-text is displayed in the InputForm. Normally it should only display "filenames", not directory-names... I checked the bool-properties in the addChildren-method and they are set as it's said in the tut.
2. When I try to expand any of the two nodes (C or Games; D is already expanded and includes "Games") I get a NullPointerException for the addChildren()-method in the first line (parent.nodeChildNode();). So the parameter "parent" is null or does at least not contain what it's expected to.
3. I have some Warnings: "TreeNodeType 'onAction.onAction': Parameters of action 'Select' and event 'onAction' are not compatible" and the same again for the second action (LoadChildren). So perhaps problem 2 can be solved by solving no 3?!
I'm stuck. Can anyone help me please?
I doublechecked that everything is as said in the tutorial.
Regards
MichaelHi
I realized I had an "Warning"-Message at my View-Context-Root-Node, where it said "Migrate Context". After I did this I get an "internal server error", Failed to process request.
Hmm, it seems as if there were a lot of changes from NW2004 to NW7.1, cause when I try to deploy the ready-to-deploy-tutorial (downloadable along with the Initial project template from SDN) I get deployment errors.
So I'll stop it now or perhaps try my own implementation (with java.io.File and recursive methods and loadable tree) to get familiar with the tree-thing in WD/Java
Thanks so far for the help, it's greatly appreciated.
Michael -
Editing non-tree cells problem in JTreeTable
Hello all,
I've been playing around with the JTreeTable for quite a while and have a fairly good grip on it. However, I've run into a problem that involves the display of cell data in the non-tree cells.
Assume I have a JTreeTable with one node below the root (and the root node is not displayed). Also assume I've edited some information in one of the other cells in a 5-celled JTreeTable. The JTreeTable behaves normally with regard to editing/setting the values of the table cells.
Now, with the click of a separate button, I programmatically create a new node in the JTree. I update the JTree model with a call to nodeChanged() and nodeStructureChanged() (or I could call reload() - both seem to work).
This successfully adds a node, but in the process clears the entire remainder of the table's cell values. If I call fireTableDataChanged(), then the display of the JTree gets all screwed up (basically what happens to the display if you add/remove nodes, but don't update the display in a JTree). Not only that, but the fireTableDataChanged() method still does not redisplay my cell information for the remainder of the table.
I'm at a loss to figure out what's responsible for this. The tableCellRenderer seems to work just fine until I add node. Even then, the tableCellRenderer for the JTree still works until I call fireTableDataChanged().
Any ideas?
Thank you,
Brion SwansonI use a JTreeTable and in looking at my code, I've
noticed that I make use of treeTable.repaint() fairly
frequently (as whenever I update my stuff).Did the treeTable.updateUI do funky things to your JTree? It does on mine if I do a programmatic node addition or removal (basically any change to the tree structure will cause treeTable.updateUI() to completely destroy the display of the tree). This is a separate issue, but I thought I'd ask anyway since you seem to have run into at least a few of the same problems I'm experiencing.
I don't fully understand your problem<snip/>
do you mean
it drops all edits you have done?Yes, it drops all the edits except the one currently being "edited" (that is, the selected editable cell will not lose it's value).
I had a problem about it dropping the edits I had
done and I resolved them by adding key listeners
and played with the TableCellEditor.Could you elaborate on what you did to the TableCellEditor and which object you had listening to the keys (the table? or the tree? or something else?).
You help is greatly appreciated!
Brion Swanson -
I am implementing an AVL tree for school assignment.
Everything has been smooth except for remove()method.
There are many different ways to implement this method, and the it is difficult to debug.
I have 5 hours left till the assignment is due, so I hope if anyone has any good examples on the remove() of AVL tree, please let me know. I have tried most links on Google and Google Code Search, but none of them suite my needs. Many of them use an extra datstructue such as queue or bitmap to do it, and some of them are too long and redundant.
My code is in reference to Weiss' Data Structure and Algorithm in Java book.
So basically I am looking for a hint on solving the problem or easy-to-read pseduoCode if possible.
Thank you and please reply as soon as you can because my time is running outHi, I'm using DefaultMutableTreeNode. On detecting a condition, I'm trying to remove a node under my root along with its children using removeNodeFromParent(); My appln just freezes and it doesn't refresh. The same code used to work with jvm_1.3.1 and all I did waz just upgrade it to 1.4.1_03; This is happening on a RedHat 9.0 Linux platform (if this matters). I tried catching Exception & Error - nothin' gets printed out. This is the snippet.
DefaultTreeModel model= (DefaultTreeModel) gethardwareTree().getModel();
HardwareTreeNode node= (HardwareTreeNode) model.getRoot();
Enumeration enumChildren = node.children();
ArrayList nodeList = new ArrayList();
// This is done to avoid using Enumeration
// Enumeration is not elegant in handling removal from its collection
while (enumChildren.hasMoreElements())
nodeList.add(enumChildren.nextElement());
Iterator rootChildren = nodeList.iterator();
while (rootChildren.hasNext())
// HardwareTreeNode is extended from DefaultMutableTreeNode
HardwareTreeNode hostNode = (HardwareTreeNode) rootChildren.next();
HardwareTreeNodeInfo currentInfo= hostNode.getTreeNode();
try {
// The following sys.out does get printed System.out.println("About to Remove: "+hostNode);
model.removeNodeFromParent(hostNode);
// The following sys.out doesn't get printed and it hangs
System.out.println("Removed: "+hostNode);
catch (Exception ex)//ArrayIndexOutOfBounds
System.out.println(ex);
Code once - use it anywhere - unfortunately didn't work??
Pls. post Ur Xperienced thoughts. -
How to solve the tree update problem
Hi all,
I met a urgent problem, I defined two tree control over two JScrollPanes.
two JScrollPanes are in a JSplitPane which is located in another JSplit's left. The left JSplitPane and another JTextarea both are in another JSplitPane.they are layouted as:
JTree1 | JTextArea
JTree2 | JTextArea
I want to achieve this: when I clicked a node in JTree1,then JTree2 is changed in the viewport according to the content of the clicked node.
I use the following essential code :
public class TNTree extends JTree {
private TemplateFrame frame1;
public TNTree(TemplateFrame frame/*,XTree tree*/)
this.frame1=frame;
getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
setShowsRootHandles(true);
setEditable(false);
try{
treeModel=initTree();
setModel(treeModel);
jbInit();
}catch(Exception e){}
this.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e) {
TreePath tp=getPathForLocation(e.getX(), e.getY());
pt.x=e.getX();
pt.y=e.getY();
try{
if((e.getModifiers()&InputEvent.BUTTON1_MASK)==InputEvent.BUTTON1_MASK)
setSelectionPath(tp);
if(e.getClickCount()==1){
if((tp!=null)&&(!isIn((DefaultMutableTreeNode)tp.getLastPathComponent())))
{ tempStr=((DefaultMutableTreeNode)tp.getLastPathComponent()).toString();
Connection con=getConnection();
PreparedStatement pstmt;
pstmt=con.prepareStatement("select content from template ,tcontent"+
" where template.tcode=tcontent.tcode and name=?");
pstmt.setString(1,tempStr);
ResultSet rset=pstmt.executeQuery();
String str="";
if(rset.next()){
str=rset.getString(1);
treeStr=str;
System.out.println(treeStr);
// frame1.xTree =new XTree(frame1,str);
// frame1.xTree=new XTree(frame1);
frame1.xTree.refresh( str );
frame1.jScroll.getViewport().add(frame1.xTree);
// frame1.repaint();
if(e.getClickCount()==2){
}else
}catch(Exception e1){e1.printStackTrace();}
public class XTree extends JTree {
private TemplateFrame frame;
public XTree(TemplateFrame frame) throws ParserConfigurationException
this.frame=frame;
refreshTextFlag=false;
strBuffer=new StringBuffer();
getSelectionModel().setSelectionMode( TreeSelectionModel.SINGLE_TREE_SELECTION );
setShowsRootHandles( true );
setEditable( false );
dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating( false );
db = dbf.newDocumentBuilder();
treeModel = buildWelcomeTree();
setModel(treeModel );
TreeTXT = "";
try{
jbInit();
catch(Exception e){
//e.printStackTrace();
Error err = new Error();
eBuffer.append(err.getValue("Err#4"));
eBuffer.append("\r\n");
public void refresh( String text ) //throws ParserConfigurationException
try{
treeModel=buildTree(text);
setModel( treeModel );
TreeTXT = text;
}catch(Exception e){
// e.printStackTrace();
Error err = new Error();
eBuffer.append(err.getValue("Err#1"));
eBuffer.append("\r\n");
public class TemplateFrame extends JFrame
static XTree xTree=null;
static TNTree tnTree;
xTree=new XTree(this);
tnTree=new TNTree(this);
jScrollLeft.getViewport().add(tnTree);
void fileOpen_ActionPerformed(ActionEvent e)
String fileName = "";
BufferedReader reader;
String line;
StringBuffer xmlText;
JFileChooser chooser = new JFileChooser();
Container parent = jMenuItem4.getParent();
int choice = chooser.showOpenDialog(parent);
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
textMessage.setText("You chose to open this file: " +
chooser.getSelectedFile().getAbsolutePath() );
// chooser.getSelectedFile().getName());
fileName = chooser.getSelectedFile().getAbsolutePath();
path=fileName;
if(fileName.substring(fileName.length()-3,fileName.length()).equalsIgnoreCase("xml"))
//Will fix future
try{
reader = new BufferedReader( new FileReader( fileName ) );
xmlText = new StringBuffer();
while ( ( line = reader.readLine() ) != null )
xmlText.append( line+"\n" );
reader.close();
//refresh the xml tree
xTree.refresh( xmlText.toString() );
textArea.setText( xmlText.toString() ) ;
/*Set the title*/
//fTitle = chooser.getSelectedFile().getName();
fTitle = chooser.getSelectedFile().getName();
this.setTitle(fTitle/*+mTitle */ );
//Sign the editor has a file
dirty = true;
}catch(Exception Mye) {
textMessage.setText("Error occured when opening the file");
}else{
textMessage.setText("Error occured when the opening file is not a xml file");
Now my problem is when in TemplateFrame cl*** I call open method including import xTree.refresh(string),I can get the right results ,the JTree2 is refreshed correctly,but when in TNTree cl*** I call the xTree.refresh(String),I met a java.lang.nullpointer exception , How can I solve this problem?
Are there other better ways to slove this problem?Hm ...
what should it be otherwise?- You said, the problem is calling frame1.xTree.refresh(str) - and the NullPointerException is thrown there - so there are only 2 possibilities - frame1 is null or xTree is null. So please add the following code before this line ...
if (frame1==null) { System.out.println("frame1 is null"); }
else if (frame1.xTree==null) { System.out.println("frame1.xTree is null"); }
else System.out.println("None of them is null - I haven't read the runtime error correctly");and then you will see, where the problem is :)
greetings Marsian -
JiveForum tree view problem in Firefox
Has anyone used the Oracle-provided JIVE Forum Viewer portlet? We have built one with the personalization function enabled, so users can go to the personalize page to select the forum they want to view in the portlet.
Everything works fine now, except that the tree menu to display all the categories and forums on the personalization page does not display or respond to mouse clicks correctly in Firefox. But if you right-click in the region of the tree menu, everything will just become fine.
We wonder if anybody can help us to identify the problem and fix it. Thank you in advance!
Yijiahi Yijia
Could this possibly be a question for the "WebCenter" forum?
WebCenter Portal
(tip : You can use "Your Control Panel" to make your name visible in forum posts.)
regards
Jan Vervecken -
Hi,
I wrote the following code to create the tree in hierarchical manner.
The following code creates three tree nodes, where each node stores
the information(con, Meas, Child and Next). When i print the nodes using
print function, it was printed all 4's as contents of 'Meas' array in all nodes.
Why it was printed only 4's as contents of 'Meas' array in all nodes? I initallized 1's and 2's as contents of 'Meas' array in first two nodes. Can any one help me in fixing the problem?
Thanks in advance
by
sudhakar
public class Tree {
private Tnode root;
class Tnode {
String Con;
float [][]Meas;
Tnode Child;
Tnode Next;
Tnode(String cword, float [][]parameters) {
Meas = new float[6][5];
Meas = parameters;
Con = cword;
Child = null;
Next = null;
public void Tree() {
root = null;
public void insert(String data, float [][]meas) {
root = insert(root, data, meas);
private Tnode insert(Tnode node, String Con, float [][]meas){
if (node==null) node = new Tnode(Con,meas);
else if (Con.indexOf(node.Con)==0)
node.Child = insert(node.Child, Con,meas);
else node.Next = insert(node.Next, Con,meas);
return node;
public void print()
if(root!=null) print(root);
public void print(Tnode node)
if(node!=null)
if(node.Con!=null) System.out.println("Con ->" + node.Con);
show(node.Meas);
if(node.Next!=null) print(node.Next);
if(node.Child!=null) print(node.Child);
void show( float [][]Meas)
for(int i=0;i<6;i++)
for(int j=0;j<5;j++)
System.out.println("N.Meas["+i+"]"+"["+j+"]="+ Meas[i][j]);
public float[][] sum(float[][]s, float [][]N)
for(int i=0;i<6;i++)
for(int j=0;j<5;j++)
s[i][j] = s[i][j] + N[i][j];
return s;
public static void main(String []v)
Tree T = new Tree();
String str[]={"Comp/Int", "Comp/Int/Inf", "Comp/Int/Inf/Wpaper"};
float [][]s = new float[6][5];
for(int i=0;i<6;i++)
for(int j=0;j<5;j++)
s[i][j] = (float)1.0;
T.insert(str[0], s); // s contains all 1's
s = T.sum(s,s);
T.insert(str[1], s); // s contains all 2's
s = T.sum(s,s);
T.insert(str[2], s); //s contains all 4's
T.print(); //displays tree
}Thanks for reply. But i was stored the contents of float[][] array (s ,
which was passed from main method) in three seperate nodes. In
node creation process, i allocated memory for new float[][] array
(Meas) in constructor. Why all the float[][] arrays are pointing to s? Yes you did allocate a new float[][] but you don't use it:Tnode(String cword, float [][]parameters) {
Meas = new float[6][5];
Meas = parameters;kind regards,
Jos -
Displaying more than one display attribute in a tree component problem
Hi,
I have a parent table and child table, I want to display a parent table's display attribute and below that i want to display child tables two display attributes (while defining the rule for a tree compoment).
What i'm getting is :
I can able to display more than one "display attributes" for my parent table, but when i'm trying to implement that for my child table under my parent table. I am only geting the blank folder structure without names.
For example:
Parent table: Deparetment(id, name)
child table: Employee(id, firstName, lastName)
What i want is:
In a Tree:-
(Department name): software below that i want display both (firstName and LastName) stephen Fleming
for that employee.Hi,
do you use ADF ? If yes, have a look at "master table with inline detail" option when dragging the master View
Frank -
Tree expand problem with Accordion Component
While using Accordion component with creationPolicy="all", tree components which are placed in accordion's different panels, will not expanded at creationcomplete.
Trees are created perfectly but not expand its level at initial creationComplete time.
If I placed tree in regular panel and executed, tree levels are perfectly expaned.
Expand level code is called at creationComplete of Tree.
Steve Roger.i got my mistake.
I am using callLater(). Now its working perfect. -
Tree component problem plz help me
Hi all,
tree component is working perfectly. But according to my requirement i need to sort the date in tree.
Iam trying that since 2 days but not able to find any solution.
can any one help me plz.
Thanks in advance.Check this thread:
ADF Sortable TreeTable
This would provide the required inputs for sorting the tree.
Thanks,
Navaneeth
Maybe you are looking for
-
The URL in Solution Manager for SRM Standard Configuration
Hi Experts, We all know that after SRM 5.0, all standard configuration guid are presented as URL in SAP Solution Manager like below: http://help.sap.com/SCENARIOS_BUS2005/helpdata/EN/ac/136341acd3001de10000000a155106/frameset.htm My question is: is t
-
HT1351 how do i add a playlist from itunes to my ipod
how do i add a playlist from itunes to my ipod? the new itunes is confusing and wont let me carry it over
-
HT2500 how to alphabetize mailboxes (mail folders) in left column of Mail application
Does anyone know how to how to alphabetize mailboxes (mail folders) in left column of Mail application? It should be easy, but I can't find a way. Thanks.
-
Processing classes , evaluation classes and cumulation classes
Hi All , Can anybody give the details of PCR in HR and how to use processing classes and evaluation classes in PCR. Regards , Santosh.
-
I Need advise with laptop-mode-tools
Hello, I installed the laptop-mode-tools to control my external harddrive. I followed closely the wiki and I managed to configure the /etc/laptop-mode/conf.d/usb-autosuspend.conf exactly, it is explained in the wiki. It works (kind of) but I don't kn