|
Below is my code
strSQL = "select Str1 from FirstTable";
<grd:dbgrid name="abc" datamember="<%=strSQL%>" datasource="<%=objCnn%>" pagesize="10">
<grd:gridpager imgfirst="images/First.gif" imgprevious="images/Previous.gif" imgnext="images/Next.gif" imglast="images/Last.gif">
<grd:gridsorter sortcolumn="<%=strSortCol%>" sortascending="<%=blnSortAsc%>">
<grd:rownumcolumn headertext="#" width="5" halign="right">
<grd:textcolumn datafield="Str1" headertext="Str1">
/**********************/
The page is displaying null table with 10 rows. No error is produce.
Any comment
Thank You
Syed Saifuddin
|
|
|
|
|
Hi I'm New to jsp. Plz help me in running this application
|
|
|
|
|
Hello,
It's really simple. Follow the steps outlined below and you are done.
1. Install Tomcat 5.x (http://tomcat.apache.org/download-55.cgi)
2. Create a directory called GridDemo under <tomcat_home>/webapps folder.
3. Copy GridDemo.xml from GridDemo.zip into <tomcat_home>\conf\Catalina\localhost folder.
4. Copy contents of web folder in GridDemo.zip into GridDemo folder created in Step 2.
5. Open GridDemo.xml and change following things to point to your own database.
a. factory (Only if you are using database other than Oracle)
b. password
c. url
d. driverClassName (Only if you are using database other than Oracle)
e. user
6. Open JDBCGrid.jsp page and change the SQL. Accordingly you will also need to change the column names given under various tags starting with "<grd:" (datafield="" attribute).
7.="" start="" the="" tomcat="" server="" by="" executing="" startup.bat="" located="" under="" <tomcat_home="">\bin folder.
8. Once it starts open the browser of your choice and type following url.
http://localhost:8080/GridDemo/jdbcGrid.do
9. If all things are configured correctly and the table contains the data you will be able to see the grid in action.
Hope this solves your problem.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
-- modified at 2:52 Tuesday 25th April, 2006
|
|
|
|
|
|
hi prasad, i follow ur steps and successfully deployed the project but while running it i got following errors in browser
Errors Starts
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/pages/JDBCGrid.jsp:27
24:
25: ctx = new InitialContext();
26: envCtx = (Context) ctx.lookup("java:comp/env");
27: ds = (DataSource) envCtx.lookup("jdbc/DBGrid");
28: objCnn = ds.getConnection();
29:
30: strTmp = request.getParameter("txtCurr");
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:994)
org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:553)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:211)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.ServletException: Cannot create resource instance
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.WEB_002dINF.pages.JDBCGrid_jsp._jspService(JDBCGrid_jsp.java:300)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:994)
org.apache.struts.action.RequestProcessor.processForward(RequestProcessor.java:553)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:211)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
Also when i start tomcat, in the dos window along with the other msg i got a msg regarding GridDemo project i am just posting that too
Jun 6, 2006 12:22:01 PM org.apache.catalina.startup.HostConfig deployDescriptor
WARNING: A docBase D:\apache-tomcat-5.5.17\webapps\GridDemo inside the host appB
ase has been specified, and will be ignored
log4j:WARN No appenders could be found for logger (org.apache.catalina.startup.T
ldConfig).
log4j:WARN Please initialize the log4j system properly.
one more thing, i am using MSSQL database
and following changes i made in GridDemo.xml file
<context path="/GridDemo" docbase="D:/apache-tomcat-5.5.17/webapps/GridDemo" debug="2">
<resource name="jdbc/DBGrid" type="oracle.jdbc.pool.OracleConnectionCacheImpl" scope="Sharable">
<resourceparams name="jdbc/DBGrid">
<parameter>
<name>factory
<value>com.microsoft.jdbcx.sqlserver.SQLServerDataSourceFactory
<parameter>
<name>password
<value>etelic
<parameter>
<name>url
<value>jdbc:microsoft:sqlserver://ETELIC4
<parameter>
<name>driverClassName
<value>com.microsoft.jdbc.sqlserver.SQLServerDriver
<parameter>
<name>user
<value>sa
Please help me out, i need this grid deadly.
Thanks
Abhishek
|
|
|
|
|
Abhishek,
Did you ever figure out what's going on with your configuration. I am running into the same problem.
Thank you
-martin
|
|
|
|
|
I am having the same problem as well. In file JDBCGrid.jsp following code snippet 3rd statement is not getting the datasource :
ctx = new InitialContext();
envCtx = (Context) ctx.lookup("java:comp/env");
ds = (DataSource) envCtx.lookup("jdbc/DBGrid");
objCnn = ds.getConnection();
I made the DSN as well with the name DBGrid, but still it is not working.
Please figure out what's going on with the configuration or any other issue.
Thanks
-- Shehzad
|
|
|
|
|
I know this is a very old thread. But I was wondering if anyone figured out the solution to this. I'm having the same problem and any help would be appreciated.
Thanks
Neha
|
|
|
|
|
Hello Neha,
How about trying out the JSP code given in the article itself. The jsp included in source uses the JNDI data source. The configuration file for the same will not work in Tomcat 5.5 & above.
Note: Don't forget to change the SQL (table name, column names) and the column names in the dbgrid tags.
Regards,
Prasad P. Khandekar
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
I hope that you can help me.
I would like to developp my own framework to developp web component with java.
this framework contains all the widget HTML.
please can you help me to do this frame work i have done it with php and i like to translate him in java (eclipse).
c'est le code en php:
name=$name;
$this->attr=array();
}
function stream() {
$s='<'.$this->name;
foreach($this->attr as $key=>$value) {
$s.=' '.$key.'="'.$value.'"';
}
$s.='>';
return $s;
}
}
//
// HTML_Collection
//
class HTML_Collection {
var $elements;
function HTML_Collection() {
$this->elements=array();
}
function add(&$element) {
$this->elements[] =& $element;
}
function stream() {
$s='';
for($i=0; $i<count($this->elements); ++$i) {
$element =& $this->elements[$i];
$s.=$element->stream();
}
return $s;
}
}
//
// HTML_Center
//
class HTML_Center extends HTML_Collection {
function HTML_Center(&$element) {
parent::HTML_Collection();
$this->add($element);
}
function stream() {
return ''.parent::stream()."\n";
}
}
//
// HTML_Page
//
class HTML_Page extends HTML_Collection {
var $css;
var $attr;
var $js;
var $js_filenames;
var $title=NULL;
function HTML_Page($css,$bgcolor) {
parent::HTML_Collection();
$this->css=$css;
$this->js="";
$this->js_filenames=array();
$this->attr['BGCOLOR']=$bgcolor;
$this->attr['MARGINWIDTH']=0;
$this->attr['MARGINHEIGHT']=0;
$this->attr['LEFTMARGIN']=0;
$this->attr['RIGHTMARGIN']=0;
$this->attr['TOPMARGIN']=0;
}
function addBR() {
$this->add(new HTML_Text(' '));
}
function add(&$element,$center=TRUE) {
if($center) {
parent::add(new HTML_Center($element));
} else {
parent::add($element);
}
}
function addJavascript($script) {
$this->js.=$script."\n";
}
function addJavascriptIncludeFile($filename) {
$this->js_filenames[$filename]=1;
}
function hasJavascript() {
return strlen($this->js) || count($this->js_filenames)>0;
}
function stream() {
$s="\n".
"\n".
(is_null($this->title)?'':'<title>'.$this->title.'').
(is_null($this->css)?'':'').
"\n\n".
"attr as $k=>$v) {
$s.=$k.'="'.$v.'" ';
}
$s.=">\n";
if($this->hasJavascript()) {
$s.="\n";
$s.=$this->js;
foreach($this->js_filenames as $filename=>$dummy) {
$s.=join("\n",file($filename));
}
$s.="\n";
}
$s.=parent::stream().
"\n".
"\n".
"\n";
return $s;
}
function echo_stream() {
echo "\n".
"\n".
(is_null($this->title)?'':'<title>'.$this->title.'').
(is_null($this->css)?'':'').
"\n\n".
"attr as $k=>$v) {
echo $k.'="'.$v.'" ';
}
echo ">\n";
if($this->hasJavascript()) {
echo "\n";
echo $this->js."\n";
foreach($this->js_filenames as $filename=>$dummy) {
readfile($filename);
}
echo "";
}
echo parent::stream().
"\n".
"\n";
}
}
//
//
//
class HTML_Text {
var $text;
function HTML_Text($text) {
$this->text=$text;
}
function stream() {
return $this->text;
}
}
//
//
//
class HTML_BR {
function HTML_BR() {
}
function stream() {
return " \n";
}
}
//
// HTML_Href
//
class HTML_Href {
var $href;
var $value;
var $target;
function HTML_Href($href,$value,$target=NULL) {
$this->href=$href;
$this->value=$value;
$this->target=$target;
}
function stream() {
$s='target").'>'.
$this->value.'';
return $s;
}
}
//
// HTML_Href
//
class HTML_HrefImg extends HTML_Href {
var $href;
var $img;
var $target;
function HTML_HrefImg($href,$img,$target=NULL) {
$this->href=$href;
$this->img=$img;
$this->target=$target;
}
function stream() {
$s='target").'>'.
''.'';
return $s;
}
}
//
// HTML_FormField*
//
class HTML_FormFieldBase {
var $name;
var $value;
function HTML_FormFieldBase($name,$value='') {
$this->name=$name;
$this->value=$value;
}
}
class HTML_RawField extends HTML_FormFieldBase {
var $string;
function HTML_RawField($string) {
$this->string=$string;
}
function stream($mode) {
return $this->string;
}
}
class HTML_InputField extends HTML_FormFieldBase {
var $size;
var $maxlength;
function HTML_InputField($name,$size,$maxlength,$value='') {
$this->HTML_FormFieldBase($name,$value);
$this->size=$size;
$this->maxlength=$maxlength;
}
function stream($mode=HTML__FORMMODE_WRITE) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s="name."\"".
" SIZE=\"".$this->size."\"".
" MAXLENGTH=\"".$this->maxlength."\"".
" VALUE=\"".$this->value. "\">";
break;
case HTML__FORMMODE_READ:
$s=$this->value;
}
return $s;
}
}
class HTML_TextAreaField extends HTML_FormFieldBase {
var $cols;
var $rows;
function HTML_TextAreaField($name,$rows,$cols,$value='') {
$this->HTML_FormFieldBase($name,$value);
$this->cols=$cols;
$this->rows=$rows;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s=''.
$this->value.
'';
break;
case HTML__FORMMODE_READ:
$s=str_replace(array("\n"," "),array(" "," "),
htmlspecialchars($this->value));
}
return $s;
}
}
class HTML_SelectField extends HTML_FormFieldBase {
var $valueList;
var $action;
function HTML_SelectField($name,$valueList,$value='',$action=NULL) {
$this->HTML_FormFieldBase($name,$value);
$this->valueList=$valueList;
$this->action=$action;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s = "name."\"";
$s.= (is_null($this->action))?'': " ". $this->action . " ";
$s.= ">";
foreach($this->valueList as $value=>$label) {
$selected=($this->value==$value)?' SELECTED':'';
$s.="".$label."";
}
$s.="";
break;
case HTML__FORMMODE_READ:
$s=isset($this->valueList[$this->value])?
$this->valueList[$this->value]:'#N/A';
}
return $s;
}
}
class HTML_MultipleSelectField extends HTML_FormFieldBase {
var $valueList;
var $size;
function HTML_MultipleSelectField($name,$valueList,$value,$size,$action=NULL) {
$value=is_array($value)?$value:array();
$this->HTML_FormFieldBase($name,$value);
$this->valueList=$valueList;
$this->size=$size;
$this->action=$action;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s='action))?'': " ". $this->action . " ";
$s.= ' SIZE='.min($this->size,count($this->valueList)).
' MULTIPLE>';
foreach($this->valueList as $value=>$label) {
$selected=in_array($value,$this->value)?' SELECTED':'';
$s.="".$label."";
}
$s.="";
break;
case HTML__FORMMODE_READ:
if(is_array($this->value)) {
$s="";
foreach($this->value as $key=>$value) {
$s.="\n";
}
$s.="".$this->valueList[$value]." | ";
} elseif (count($this->value)==0) {
$s=" ";
} else {
$s=$this->valueList[$this->value[0]];
}
}
return $s;
}
}
// Deprecated
//
class HTML_CheckboxField extends HTML_FormFieldBase {
function HTML_CheckboxField($name,$value=NULL,$action=NULL) {
$value=(is_null($value))?FALSE:$value;
$this->HTML_FormFieldBase($name,$value);
$this->action=$action;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s='action))?'': " ". $this->action . " ";
$s.= ($this->value?' CHECKED':'').'>';
break;
case HTML__FORMMODE_READ:
$s=($this->value?'TRUE':'FALSE');
break;
}
return $s;
}
}
class HTML_CheckboxValueField extends HTML_FormFieldBase {
var $checked;
var $action;
function HTML_CheckboxValueField($name,$value=NULL,$checked=NULL,$action=NULL) {
$this->HTML_FormFieldBase($name,$value);
$this->checked = ( is_null( $checked ) ) ? FALSE : $checked;
$this->action = $action;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s='value)) ? '' : ' VALUE="'.$this->value.'"';
$s.= (is_null($this->action)) ? '' : ' '.$this->action.' ';
$s.= ( $this->checked ? ' CHECKED' : '' ).'>';
break;
case HTML__FORMMODE_READ:
$s = ( $this->checked ? 'TRUE' : 'FALSE' );
break;
}
return $s;
}
}
class HTML_RadioField extends HTML_CheckboxValueField {
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s='value)) ? '' : ' VALUE="'.$this->value.'"';
$s.= (is_null($this->action)) ? '' : ' '.$this->action.' ';
$s.= ( $this->checked ? ' CHECKED' : '' ).'>';
break;
case HTML__FORMMODE_READ :
$s = ( $this->checked ? 'TRUE' : 'FALSE' );
break;
}
return $s;
}
}
#'';
class HTML_FileField extends HTML_FormFieldBase {
var $size;
var $maxlength;
function HTML_FileField($name,$size='',$maxlength='') {
$this->HTML_FormFieldBase($name,'');
$this->size=$size;
$this->maxlength=$maxlength;
}
function stream($mode) {
switch($mode) {
case HTML__FORMMODE_WRITE :
$s='';
break;
case HTML__FORMMODE_READ:
$s='';
break;
}
return $s;
}
}
//
// HTML_Button*
//
class HTML_ButtonBase {
var $label;
var $name;
function HTML_ButtonBase($label,$name='') {
$this->label=$label;
$this->name=$name;
}
}
class HTML_SubmitButton extends HTML_ButtonBase {
function HTML_SubmitButton($label, $name) {
$this->HTML_ButtonBase($label, $name);
}
function stream() {
$s='';
return $s;
}
}
class HTML_SubmitButtonImage extends HTML_ButtonBase {
var $picture;
function HTML_SubmitButtonImage($label,$name,$picture) {
$this->HTML_ButtonBase($label, $name);
$this->picture=$picture;
}
function stream() {
$s='label.'\">';
return $s;
}
}
class HTML_HrefButton extends HTML_ButtonBase {
var $href;
var $target;
function HTML_HrefButton($label,$name,$href,$target=NULL) {
$this->HTML_ButtonBase($label,$name);
$this->href=$href;
$this->target=$target;
}
function stream() {
$href =& new HTML_Href($this->href,$this->label,$this->target);
return '['.$href->stream().']';
}
}
class HTML_WizardHrefButton extends HTML_HrefButton {
var $js;
function HTML_WizardHrefButton($label,$href,$windowProperties=array(),$windowName='') {
parent::HTML_HrefButton($label,NULL,'javascript:void(0)');
$this->js="window.open('$href','$windowName'";
$features=array();
if(is_array($windowProperties)) {
foreach($windowProperties as $name=>$value) {
$features[]=$name.'='.$value;
}
}
if(count($features)!=0) {
$this->js.=",'".implode(',',$features)."'";
}
$this->js.=')';
}
function stream() {
$s='href.'"'.
' ONCLICK='.'"'.$this->js.'"'.'>'.
$this->label.
'';
return '['.$s.']';
}
}
class HTML_InputButton extends HTML_ButtonBase {
var $js;
function HTML_InputButton($label,$name,$formname='myform') {
$this->HTML_ButtonBase($label,$name);
$this->js='buttonClicked('.$formname.',"'.$this->name.'")';
}
function stream() {
$s='js.'\'>';
$s.="\n";
return $s;
}
}
?>
Merci
|
|
|
|
|
Hello,
I really don't know much about PHP, but know it for sure that there is not a direct way to convert PHP into java. Also regarding various HTML widget's you have developed you amy want to take a look at struts taglibrary. It includes lot's of HTML widgets.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Hai, i am using limit query (example "select * from tablename limit 500") suppose if we have 1000 records in table while displaying it display 500 rows correctly but it disply empty pages for the remaining 500 records.
How can i prevent displaying empty pages.
Durgaprasad
|
|
|
|
|
Help,
You can have a look at RawJDBCGrid.jsp page. It demonstrates another way of using DBGrid control with full control in the developer's hand.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
displaytag library also provides similar features.
How is this different from displaytag library ?
|
|
|
|
|
Hello,
I don't think functionality wise it's much different than displaytag library. Although there are differences in the ways displaytag library accesses the data, the configuration information.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
hi,
i have a error when run de example, i'm using the Mysql database but the error is for inconvertible types.
this is report of the error,
An error occurred at line: 90 in the jsp file: /calen.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\jakarta-tomcat-5.0.9\work\Catalina\localhost\PR\org\apache\jsp\calen_jsp.java:152: inconvertible types
found : com.freeware.gridtag.DBGrid
required: javax.servlet.jsp.tagext.SimpleTag
if (_jspx_th_grd_dbgrid_0 instanceof javax.servlet.jsp.tagext.SimpleTag)
^
An error occurred at line: 90 in the jsp file: /calen.jsp
Help Me
Please
Juan Manuel Carrascal.
Buenos Aires.
Argentina.
Estoy muy interesado en ver codigo jsp
|
|
|
|
|
Hello,
Can you share the JSP page you have written. I can then take a look at it and diagnose the problem.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Hi,
I want to run RawJDBCGrid.jsp I get "Unable to find setter method for attribute: totalRecords" error ?
Anyone can help me ?
Thanks,
|
|
|
|
|
hello,
In my database i have 3 records
test1
test2
test3
and when i set pageSize="2"
it's displaying 2 pages of 2 records
page 1 --> test1,test2
page 2 --> test2,test3
how can i display
page 1 --> test1,test2
page 2 --> test3,%empty%
thanks
|
|
|
|
|
Hello,
Thank's lot for pointing out the bug in record navigation. I have fixed this problem and uploaded the updated demo and source.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
I have implemented a "ListGrid", and I would like to be able to sort on the columns. I have implemented comparable in the objects that I'm passing with the list. Of course it sorts the way that is specified in "compareTo(Object)". I guessing that if I want it to sort by another field, the row object needs to be able to pass the name of the field I want to sort on, and the direction of the sort to the objects in the list, and in the object I need to return the compare value based on the field selected for sorting. Is this correct?
Thanks,
Dave
|
|
|
|
|
Nevermind...
In DBGrid, there is not a sort capability built into the code for Lists, so I updated my copy the code to sort Lists. I created an abstract rowObject that has a sortColumn and sortDirection variable. The bean implements also Comparable, and does its comparison based on row and direction for each available column.
The object beans for the List passed into DBGrid must extend rowObject for the sort to work. (Lists with objects that are not of type rowObject will not be sorted.)
As the List is iterated through, the sortColumn and sortDirection are set on each bean. Finally, the list is sorted and the display updated.
There is probably an easier method to do this - or at least one that does not require the bean to know its own sort column (variable) and direction. I just don’t know it. If anyone has a suggestion on a better way to do this, please let me know.
Thanks,
Dave
|
|
|
|
|
hi
thank u for showing intrest,we have got edit function working
we want to implement inbox.jsp using grid,to veiw the new received messages. the subject of the new message in the grid should be a clickable link and on clicking it message should expand,similar to the message board on this website
gec2006
|
|
|
|
|
Hello,
Unfortunately this is not supported by DBGrid. Let me see whether I can this behavior in future release.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
we want to implement inbox using datagrid.inbox should function as follows:
every new message should be a link in the row of the datagrid.and every time
we click the link the message should open something like how u have used it for FAQ veiwing the messages.plz send us code for the same
thanking u
goa engineering student
|
|
|
|
|