|
-
Components
Hello,
Are there components available for automating Calendar dropdowns and DBGrids
with JSP?
What is the best framework for multiuser ability with a database? We are
considering and extra field that would increment when a user would open a
record for editing. And, then deny updates if the number changes.
-
Re: Components
Greg Critcher <gcritcher@nsi3.com> wrote:
> Are there components available for automating Calendar dropdowns and DBGrids
> with JSP?
I don't know of any widely used ones. On the calendar front, if
you're looking for something consisting of three dropdowns, one for
day, month, and year, you could just have the dropdowns in html,
as in:
<select name="day">
<option value="01">1
<option value="02">2
...
</select>
<select name="month">
<option value="01">January
<option value="02">February
...
</select>
Then, to use these values, you'd just need a simple bean that would
receive the values and convert them to a Date. Here's a basic
version:
import java.text.*;
import java.util.Date;
public class DateHandler {
private DateFormat df = new SimpleDateFormat("MM/dd/yyyy");
private String day;
private String month;
private String year;
public void setDay(String day) {this.day = day;}
public String getDay() {return day;}
public void setMonth(String month) {this.month = month;}
public String getMonth() {return month;}
public void setYear(String year) {this.year = year;}
public String getYear() {return month;}
public Date getDate() {
try {
return df.parse(month + "/" + day + "/" + year);
} catch (Exception e) {
return new Date();
}
}
public static void main(String argv[]) {
DateHandler h = new DateHandler();
h.setMonth(argv[0]);
h.setDay(argv[1]);
h.setYear(argv[2]);
System.out.println(h.getDate());
}
}
This uses Strings instead of integers for the day, month and year to
make things easier for the DateFormatter to parse. Note that this
will do weird things on invalid dates, like January 32, 2001.
If you're looking for a fancier way to prompt for dates, there's a
sample of a JSP example that displays a calendar view of the current
month, available from
http://www.weblogic.com/docs51/intro/intro_jsp.html. It should be
possible to modify this to make each date a link or checkbox.
As for DBGrids, I don't know of any packages to generate tables
automatically. My book goes into some detail on using databases with
JSPs, some of the information there should (hopefully!) be useful.
The easiest thing for page developers to use would be a custom tag,
where you could write something like this to generate a list of tracks
and times from a CD (this is part of listing 14.14 from the book):
<TABLE BORDER="1">
<TR><TH>Name</TH><TH>Length</TH></TR>
<awl:tracks CD="Liquid">
<TR>
<TD><%= name %></TD>
<TD><%= length %></YD>
</TR>
</awl:tracks>
</TABLE>
> What is the best framework for multiuser ability with a database? We are
> considering and extra field that would increment when a user would open a
> record for editing. And, then deny updates if the number changes.
Many databases, such as Oracle, will handle this for you
automatically. I think Postresql does as well, but you may need to
explicitly start and end the transaction. However, your proposed
solution seems to be a good one for databases that don't support
transactions.
- Larne
--
The fairy told Billy "no." Billy then found that the fairy's head
was squishy, like a grape.
from Lenore #3, by Roman Dirge
Similar Threads
-
By Valarmathy in forum Java
Replies: 0
Last Post: 01-19-2002, 05:35 AM
-
By Zane Thomas in forum dotnet.announcements
Replies: 0
Last Post: 10-17-2001, 10:51 PM
-
By Zane Thomas in forum .NET
Replies: 0
Last Post: 10-17-2001, 02:37 AM
-
By Miha Markic in forum .NET
Replies: 12
Last Post: 01-29-2001, 03:57 AM
-
By Keith Delaski in forum Enterprise
Replies: 3
Last Post: 01-10-2001, 08:53 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks