How to get Tree structure in JSP page?
Hi,
I would like get data from the database and display the data in tree structure with the check boxes at each nodes on a jsp page with out using any third party tools. how can i do that? Do i require any new tags to fulfill this requirement?
can any one help me out by sending any example code?
thanks in advance.
Regards,
Reddy
Once you have the data in a list or something, can't you just use <c:forEach> and then output standard nested <ul> and <li> tags to give the tree structure.
<html>
<style>
li
list-style-type:none;
</style>
<body>
<form>
<ul>
<li>
<input type="checkbox">Check 1</input>
<ul>
<li>
<input type="checkbox">Check 1A</input>
</li>
<li>
<input type="checkbox">Check 1B</input>
</li>
</ul>
</li>
<li>
<input type="checkbox">Check 2</input>
<ul>
<li>
<input type="checkbox">Check 2A</input>
</li>
</ul>
</li>
<li>
<input type="checkbox">Check 3</input>
</li>
</ul>
</form>
</body>
</html>
Similar Messages
-
How to get tree structure navigation in module pool program
please send me a sample code for getting tree structure navigation in a screen in module pool program.
ex.
masters
itemsdo a chain and endchain on the fields.Then insert the fields in to the required database.
-
How to get multiple selections from jsp page in my servlet
Hello Everyone,
I've a list that allows users to make multiple selections.
<select name=location multiple="multiple">
<option>
All
</option>
<option>
Hyd
</option>
<option>
Dub
</option>
<option>
Mtv
</option>
</select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
ArrayList locList = new ArrayList();
locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
Please let me know.For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/] -
How to get ep authority in jsp page
Hi all:
I want to create a j2ee project and some jsp pages to deploy to EP server.
My question is how to get user name or user authority in jsp page.
Is there any APIs to use or something else.
Thanks in advance.
AllenHai ,
I Think This will help ful for u check it ,
File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10, new TraceFormatter());
The above code specifies the path for your log file.
Then add this file as a log location and then log the traces. For this you can use the following code like:
Location location=Location.getLocation(className);
location.addLog(file);
location.setEffectiveSeverity(Severity.ALL);
location.entering(methodName);
To Create j2ee apllication
In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
So as you are using this in Portal Application, this does not work.
You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
In this Web Module Project, try creating JSP, this will work.
So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
Regards ,
venkat -
How to get table headers in jsp page
hi,
this is praveen, can any one help me to solve this problem.
how to get table headers in a jsp page. whether it is possible using javascript or is there any other way.
pls send rep.
thank u.Hai ,
I Think This will help ful for u check it ,
File=new FileLog("f:/WebServiceTrace/trace2.%g.log", 800000, 10, new TraceFormatter());
The above code specifies the path for your log file.
Then add this file as a log location and then log the traces. For this you can use the following code like:
Location location=Location.getLocation(className);
location.addLog(file);
location.setEffectiveSeverity(Severity.ALL);
location.entering(methodName);
To Create j2ee apllication
In path new-j2ee-jsp to create JSP's can only be used for J2EE applications.
So as you are using this in Portal Application, this does not work.
You can test this bahavior by creating a new Web Application (New-Project-J2EE-Web Module Project)
In this Web Module Project, try creating JSP, this will work.
So dont use new-j2ee-jsp to create JSP in Portal Application instead use New-File and name the file as jsp.
Regards ,
venkat -
How to get tree structure from file list?
I have got following rows from my select query presenting a folder structure:
PATH
/KING/JONES/SCOTT
/KING/JONES/SCOTT/ADAMS
/KING/JONES/FORD
/KING/JONES/FORD/SMITH
/KING/BLAKE
/KING/BLAKE/ALLEN
/KING/BLAKE/WARD
/KING/BLAKE/MARTIN
/KING/BLAKE/TURNER
/KING/BLAKE/JAMES
/KING/CLARK
/KING/CLARK/MILLER
/PALO/TEMP
On base of this data I need to build tree in my application by effecient way.
Therefore i would like to achieve data (SELECT with two columns) as bellow:
FOLDER PARENTFOLDER
KING NULL
JONES KING
SCOTT KING/JONES
ADAMS KING/JONES/SCOTT
FORD KING/JONES
SMITH KING/JONES/FORD
BLAKE KING
ALLEN KING/BLAKE
WARD KING/BLAKE
MARTIN KING/BLAKE
TURNER KING/BLAKE
JAMES KING/BLAKE
CLARK KING
MILLER KING/CLARK
PALO NULL
TEMP PALOIs this possible to do it on SQL level(not PL SQL)?
ThanksPerhaps something like this?
SQL> ed
Wrote file afiedt.buf
1 with t as (select '/KING/JONES/SCOTT' as path from dual union all
2 select '/KING/JONES/SCOTT/ADAMS' from dual union all
3 select '/KING/JONES/FORD' from dual union all
4 select '/KING/JONES/FORD/SMITH' from dual union all
5 select '/KING/BLAKE' from dual union all
6 select '/KING/BLAKE/ALLEN' from dual union all
7 select '/KING/BLAKE/WARD' from dual union all
8 select '/KING/BLAKE/MARTIN' from dual union all
9 select '/KING/BLAKE/TURNER' from dual union all
10 select '/KING/BLAKE/JAMES' from dual union all
11 select '/KING/CLARK' from dual union all
12 select '/KING/CLARK/MILLER' from dual union all
13 select '/PALO/TEMP' from dual
14 )
15 --
16 -- END OF TEST DATA
17 --
18 select distinct substr(path,instr(path,'/',1,rn)+1,decode(instr(path,'/',1,rn+1),0,length(path)+1,instr(path,'/',1,rn+1))-instr(path,'/',1,rn)-1) as folder, substr(path,2,instr(path,'/',1,rn)-2) as parent
19 from t
20 cross join (select rownum rn from dual connect by rownum <= (select max(length(regexp_replace(path,'[^/]'))) from t)) x
21* where instr(path,'/',1,rn) > 0
SQL> /
FOLDER PARENT
BLAKE KING
SCOTT KING/JONES
JAMES KING/BLAKE
MARTIN KING/BLAKE
SMITH KING/JONES/FORD
KING
WARD KING/BLAKE
ADAMS KING/JONES/SCOTT
FORD KING/JONES
TURNER KING/BLAKE
MILLER KING/CLARK
PALO
TEMP PALO
JONES KING
CLARK KING
ALLEN KING/BLAKE
16 rows selected.
SQL> -
How to get current time in jsp page?
my problem is :-
i have a radio buttons with name as 9am, 11am ,1pm, 3pm , 5pm , 7pm , 9pm , 11pm , 1am , 3am ,5am 7am. what ever the current time may be the radio button of four hour plus than current time should be atomatically checked and previous radio buttons should be disabled. for example suppose current time is 11.02am than the radio button of 3pm should be automatically checked and previous radio buttons should be disabled.
please help me if u can?This should work but it needs testing out around midnight ( not sure if it is 00:00 or 24:00):
<%@ page import="java.util.*" %>
<html>
<head><title>Time Page</title>
</head>
<body>
<% Calendar c = Calendar.getInstance();
c.add(Calendar.HOUR_OF_DAY, 4);
int h = c.get(Calendar.HOUR_OF_DAY); %>
The current hour is <%= h %><br>
<% for (int i=0; i < 24; i++) { %>
<input type=radio name=time <%= (i < h) ? "disabled" : ""%><%= (i == h) ? "checked" : ""%>><%= (i < 10) ? "0" : ""%><%= i %>:00<br>
<% } %>
</body>
</html> -
How to get Parameters in a jsp page called by VB program via xmlHttp
I have a VB programm sending a request using xmlHttp.
xmlHttp.Open "POST", varTarget, True 'True means asynchronous
xmlHttp.Send xmlSendStr
This worked fine with ASP
the crucial ASP code was:
set xml = server.createObject("MSXML2.DOMDocument")
xml.load(request)
VBData = cstr(xml.getElementsByTagName("value").item(0).firstChild.nodeValue)
now I have a webserver (tomcat) and try to have a simular functionality
but
request.getParameter()
seems not to do the job.
what do I have to do
I am thankfully looking forward to you reply
peterHi,
thanks for your reply!
If I have the parameters in the URL and use the method GET it works all right.
but I need the method to be POST. I suppose, I have the wrong way identifying the parameter name
This is from VB
varTarget = "http://localhost:9090/gm/getData" ' getData is my servlet
xmlSendStr = "SQLStmt=SELECT TCPD_Cars.* From TCPD_Cars WHERE (((TCPD_Cars.CarIdent)=45));"
xmlHttp.Open "POST", varTarget, True 'True means asynchronous
xmlHttp.Send xmlSendStrthis is part of my Servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter writer = response.getWriter();
String SQLStmt = request.getParameter("SQLStmt") ;
//make the database query and get the returns
writer.println(GetSQLData(SQLStmt));
//close the write
writer.close();
}I would appreciate any suggestions -
How to get the view tree from a jsp page
Hi,
I would like to get the view tree of a jsp page. The idea is to dynamically include the content of one or more jsf pages into a UIPanel during a "value changed" event.
So, i could get from an arbitrary page like ...
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<h:panelGrid columns="3" width="100%" rowClasses="gridTop">
<h:outputText value="#{someBean.someValue}"/>
</h:panelGrid>... the corresponding List of components...
Any idea?Thanks for your answer Jayashri,
The view tree can be retrieved by this way during the page is parsed, for example with scriptlets <%%>, or once the page has been parsed (the view has been builded and attached to the FacesContext).
My problem is to get the view tree of a page from another Context.
The idea is to build a dynamic layout of some pages that represents "views". I can imagine this like the concept of perspectives and views of Eclipse IDE.
Because of the difficulty to build it with pure JSP (cannot use dynamic ID nor JSTL ForEach), I try to build it into my backing bean and to bind it with a <h:panelGrid/>. By this way, I'm not able to use the <jsp:include/> tag as I usually did to include some content into the view tree.
Sorry for my english ;)
- Renaud. -
Hi,
I have an xml file , my requirement needs me to display the xml file as a tree structure in jsp. The user should be able to make changes to tree. he can drag and drop the nodes and save the changes.
I parsed the xml file and created a method that returns an arrayList of the immediate children given a node.I'am not getting how to proceed from there on.
Can anyone provide me with any useful tips or code. I can use javascript css java(not swing).Please reply ASAP as I have to complete it soon.
Thanks,
SabiHi why dont you try the link below,
basically its for menu u can change it,
http://demo.raibledesigns.com/struts-menu/
in the above link see the following hyperlink
Expandable DHTML List Example - Shows Expandable DHTML list -
How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
using RequestDispatcher..its not possible..becoz
RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
rd.foward(req,res);
Here the request and response are null objects..
So mi question can frame as how can i get request/response in servlet's init method()..Hi guys
did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:519)
at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
so plz do let me know how to call a jsp in the start up of a servlet.
Thanks
Vidya -
How to enable the EL in jsp page
hi can u tell 'how to enable the EL in jsp page'?
*I am getting below exception in tomcat when i inclued +<%@ page isScriptingEnabled="true" isELEnabled="true"%>+*
org.apache.jasper.JasperException: /index.jsp(1,1) Page directive has invalid attribute: isScriptingEnabled
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:311)
org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)
org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
org.apache.jasper.compiler.Validator.validate(Validator.java:1700)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803) -
How to Hightlight the Data in Jsp Page
How to Hightlight the Data in Jsp Page,
I am doing doing search page,based on values given search page those are sent to servlet,in servlet based on some conditions if particuler id i am getting then i am redirecting to Respective jsp page with highlight the data from database..
Thanks in advance..."Highlighting data in JSP sounds strange".
Without looking at your search specific algorithms I feel you are finally going to display a page (HTML content) to user which contains highlighted text. Highlighting is not directly related to server side language you use (JSP, ASP, PHP etc.). This is purely HTML and CSS. However, server side script (such as JSP) should generate HTML content for getting highlight effect.
Following HTML shows highlighted text using background-color property on span element.
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>
<body>
<p style="font-size:1.1em">This is a long paragraph which contains <span style="background-color: yellow;">highlighted text</span> and non highlighted text.</p>
</body>
</html>Thanks,
Mrityunjoy
Edited by: mrityunjoy on 14 Jun, 2010 3:30 AM -
How to debug a bean in JSP page with JBX???
How to debug a bean in JSP page with JBX???
i have a bean within a JSP page. i wanna find out how do they varibles work and changes of them values.
are there some ways or tools to get the situations of them in visual way? just like when i debug VB program,i can get the situations in immediately window.help me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
t:tree component is not rendering tree structure for my page
Dear dudes,
I want to create a simple tree structure in my jsf page backed by a backing bean.
But my jsf page is getting executed but my tree is not getting displayed.
my jsf page:<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:rich="http://richfaces.ajax4jsf.org/rich"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax">
<f:view>
<html>
<body>
<h:form>
<t:tree id="tree" value="#{mytreeBean.myTree}" styleClass="tree"
nodeClass="treenode" selectedNodeClass="treenodeSelected"
>
</t:tree>
</h:form>
</body>
</html>
</f:view>
</ui:composition>Mybacking bean:
package org.test.tree;
import java.util.Iterator;
import java.util.List;
import org.apache.myfaces.custom.tree.DefaultMutableTreeNode;
import org.apache.myfaces.custom.tree.model.DefaultTreeModel;
import com.srit.framework.web.BasePage;
import com.srit.healthcare.common.lookupentity.repository.ILookupRepository;
import com.srit.healthcare.common.tree.domain.RcareTree;
public class MyTreebean {
private DefaultTreeModel myTree;
public DefaultTreeModel getMyTree() {
return myTree=getTreeModel();
public void setMyTree(DefaultTreeModel myTree) {
this.myTree = myTree;
/*public MyTreebean() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
root.insert(a);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
root.insert(b);
DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
root.insert(c);
DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");
a.insert(node);
node = new DefaultMutableTreeNode("a2 ");
a.insert(node);
node = new DefaultMutableTreeNode("b ");
b.insert(node);
a = node;
node = new DefaultMutableTreeNode("x1");
a.insert(node);
node = new DefaultMutableTreeNode("x2");
a.insert(node);
myTree = new DefaultTreeModel(root);
public DefaultTreeModel getTreeModel() {
DefaultMutableTreeNode root = new DefaultMutableTreeNode("XY");
DefaultMutableTreeNode a = new DefaultMutableTreeNode("A");
root.insert(a);
DefaultMutableTreeNode b = new DefaultMutableTreeNode("B");
root.insert(b);
DefaultMutableTreeNode c = new DefaultMutableTreeNode("C");
root.insert(c);
DefaultMutableTreeNode node = new DefaultMutableTreeNode("a1");
a.insert(node);
node = new DefaultMutableTreeNode("a2 ");
a.insert(node);
node = new DefaultMutableTreeNode("b ");
b.insert(node);
a = node;
node = new DefaultMutableTreeNode("x1");
a.insert(node);
node = new DefaultMutableTreeNode("x2");
a.insert(node);
return myTree = new DefaultTreeModel(root);
}Also i've configured my tomahawk-taglib file in my web.xml .
My backing bean is configured in my faces-config.xml
But i'm not able to get my tree structure in my page .
Any help would be appreciated.
RegardsDear akash,
yes i'm seeing the jsf tags <t:tree>
But when i modify my jsf page , in my configuration files i'm getting the following errors:
In web.xml
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
</web-app>
error message: cannot find the declaration of element web-apps
error message: failed to read schema document http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd because 1) couldnot find the document 2) the document could not be read 3) the root element of the document is not <xsd:schema>In another configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
Error: cannot find the declaration of element 'beans'I'm a novice to JSF technology and plz guide me properly.
Maybe you are looking for
-
No advanced option on photo downloader screen.
Photoshop 8. When importing pictures, the photo downloader screen is missing the "Advanced" button that is supposed to be in the lower left hand corner. As a test, we installed the same software on another computer and there, the downloader display
-
Where are my 'to do' items in Calendar?
I've just upgraded to Mavericks. A feature that I used to use all the time in iCal, the To Do list, seems to have disappeared in 'Calendar'. I'm lost without it. Can I retrieve my existing "To Do's"? It contains my list of what I have to do this week
-
When posing a ABAP Proxy as WebService in XI, the tester shows the following message when tested. <SOAP:Fault> <faultcode>SOAP:Server</faultcode> <faultstring>failed to call the adapter engine</faultstring> <detail>
-
hi all, can anybody tell me the logic to impliment following thing in zreport. eg= number = 12345. addition = 1 + 2 + 3 + 4 + 5. result = 15. please give me the logic to add digits of the number. thanks in advance. regds. Vinod.
-
OPATCH_JAVA_ERROR : An exception of type "OPatchException" has occurred:
Hello Gurus, i have run coomand: opatch lsinventory -detail it gives me error as follows: kindly advice to resolve the issue. opatch lsinventory Oracle Interim Patch Installer version 1.0.0.0.57 Copyright (c) 2007 Oracle Corporation. All Rights Reser