Solved

Dynamic table

Posted on 2003-10-27
16
576 Views
Last Modified: 2008-02-26
I have a jsp form called view.jsp.

When the user clicks the add button, a pop window would pop up and asks the user to enter the details such as

  Name of Color,
  Type of Color,
   Description,
When the user has entered the details, he presses the ok button on the pop up window, the data gets inserted into the database
(The user could add as many as color and details and table grows)

My problem is that i need to display the details of the color in a dynamic table( i don't know how) with a checkbox and the details
For example
Checkbox | Name of Color|Type of Color|Description

How do i add this to the dynamic table and i need not explicits refresh the view the jsp( i don't know how)

The name of table is Col
Fields
Colorid | typeColor| Desc|

Thanks
0
Comment
Question by:Jasbir21
  • 6
  • 5
  • 5
16 Comments
 
LVL 2

Expert Comment

by:Karaa
ID: 9626655
the details  of color are coming from db or some where else?
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9626685
<%
String cname;/// coming from db
String   check="checked"; or check="";/// this check variable may have two values coming from database either "checked" or ""
%>
use some For loop

<td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.print(check);%>><br></td>
<input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" >
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9626720
if u want to do SQL search of table from db u can use
String      str = "SELECT color,type,desc,checked FROM Col";
            rset = stmt.executeQuery(str);%>
<%
            while (rset.next())
                  {
                  String cname= rset.getString(1);
                  String type= rset.getString(2);
String desc= rset.getString(3);
String checked= rset.getString(4);

                  %>
                  <td width="5"><input type="Checkbox" name="gar" value="pot" <%  out.println(checked);%>><br></td>
<td ><input name="color" type="text" id="colorname" value="<%=cname%>" size="19" align="top" width="110" > </td>      
<td ><input name="type" type="text" id="type" value="<%=type%>" size="19" align="top" width="110" > </td>      
<td ><input name="desc" type="text" id="desc" value="<%=desc%>" size="19" align="top" width="110" > </td>                  <%      }      %>
0
 

Author Comment

by:Jasbir21
ID: 9627352
Hi,
 
  I tried that but i got this error:server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


root cause

java.lang.NullPointerException
      org.apache.jsp.jsp2.orga_jsp._jspService(orga_jsp.java:259)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9627366
if you don't want to refresh the view.jsp, then there is an example of how to do it with javascript:
http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20676182.html
it was about another question but have the right example in it.
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9630309
The reason may be you have not initialised JSP variables
0
 
LVL 2

Expert Comment

by:Karaa
ID: 9630313
it is better you post your code
0
 

Author Comment

by:Jasbir21
ID: 9687185
....java bean classes and connection with database
My problem is that when the user clicks the new button , the project.jsp should be displayed and when the info is entered the page needs to be refreshed or what ever (dynamic table needs to be displayed)
Could anyone plssssssssss help me , i really  needs this urgently

This is the part of the code:

<table border="2" BGCOLOR="#FFFFF0" width="80%" CELLPADDING="4">
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
Project Name
</td>
<td>
Description
</td>
<td>
Duration
</td>
<td>
Skills Required
</td>
</tr>
</table>

</p>
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">
</p>
<input type="submit" value="Submit">
</form>
</font>
</body>
</html>
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Expert Comment

by:kennethxu
ID: 9687616
>> Could anyone plssssssssss help me , i really  needs this urgently
we need more information to help you, you might want to help you self by response to us quickly.

can you please post what you have for your view.jsp? or let us know if you don't even know where to start.
0
 

Author Comment

by:Jasbir21
ID: 9698033
so sorry for the late response.

 I don't know where to start, except that my connections the database and everything works fine, and for the dynamic table part i just have that html code,
The rest of the form is just enterin g data...


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9698530
assuming you know how to get a resultset from database:

<% while( resultSet.next() ) { %>
<tr>
<td>
<input type="checkbox" name="chk" value="yes" style="background=cornsilk; border=0;">
</td>
<td>
<%=resultSet.getString( "ProductName" )%>
</td>
<td>
<%=resultSet.getString( "Description" )%>
</td>
<td>
<%=resultSet.getString( "Duration" )%>
</td>
<td>
<%=resultSet.getString( "SkillsRequired" )%>
</td>
</tr>
<% } %>
0
 

Author Comment

by:Jasbir21
ID: 9698806
Hi,
  Sorry for not being clear from the beginning :
<input type=button value="New" >
<input type=button value="Edit">
<input type=button value="Delete">

 My problem when the user clicks the new button, a window should pop up, called project.jsp.
Where the user is able to enter data into table project.When the user clicks submit button on project.jsp the dynamic table in view.jsp needs to be displayed.
There is also other information entered by the user on view.jsp.
I mean, how can it be done if the user
clicks new, the project.jsp pops-up ,user enters info press submit, it gets displayed on view.jsp(dynamic table) with other info of user..


Thanks
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9702479
so your question is rather on how to handle the popup windows instead how to display a dynamic table with data from database.

read this thread from beginning to the end and you should know what you need to do.

Let me know if you have futher enquires.
0
 
LVL 14

Accepted Solution

by:
kennethxu earned 150 total points
ID: 9709782
0
 

Author Comment

by:Jasbir21
ID: 9751764
thank you ans sorry for the late reply....
0
 
LVL 14

Expert Comment

by:kennethxu
ID: 9752902
glad to know your problem is resolved and thanks for the A grade.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
maven project import to eclipse problems 13 94
grep code 4 154
IE doesn't Invoke servlet in iframe 1 94
maven project jars 7 46
A safe way to clean winsxs folder from your windows server 2008 R2 editions
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now