|
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
|
|
|
|
|
|
Hello,
The most simple implementation of function would be as shown below. This function assumes that you have a hidden form named frmEdit containing following fields
1. txtParent
2. txtEntity
function doEdit(pstrParent, pstrEntity)
{
var editForm;
editForm = document.frmEdit;
if (!editForm) return;
editForm.txtParent.value = pstrParent;
editForm.txtEntity.value = pstrEntity;
editForm.action = "<url of edit page>";
editForm.submit();
}
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
can we offer to select rows into DBGrid and let them update and delete. i want to make a column that contain either checkbox or radiobutton according to requirement delete and update. Is it possible with the available TLD's if yes give details.
sandy rathi
S/W Engineer
25 years old
|
|
|
|
|
Hello,
If you closely look at the demo pages you will notice that one of the column is made as image column and gives a call to javascript function which also takes some arguments. Your requirement should get solved by this approach. The javascript function inthe demo at presnt does nothing. But you could actually post values from this function along with a desired action identifier and perform the action on server side.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Thanks for the code, it is very easy to install and use.
I am using it to prototype a Struts application. I am using the tag library to display a List of Objects. Server = Tomcat 5.5. Action is set to request scope.
I am seeing strange behavior. I have a JSP and a Form Bean. The first time a user connects to the JSP, they have to enter search criteria, so the List is set to empty. Next, they enter search criteria and the Action class populates the List in the Form Bean. The JSP with the grid tag gets the data and displays it nicely.
The strange behavior occurs when I logout. If I have another user connect to the app from another client machine, they see the LAST data that I retrieved. I have proven that the Form Bean does contain an empty list (with simple iterate tag), however, the tag library is still showing last List (almost like it is stored as an application variable).
Any ideas?
Thanks
|
|
|
|
|
Hello,
Can you share the code with me so that I can take a look at it and let you help in dignose this issue.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
Sure, any help you can provide would be appreciated. I really like the ease of use of the grid, but am concerned about multi-user issues (as I can go to another machine, connect to the website, and see the "last" user's results in the grid -- of course, this is probably configuration issue on my end).
Also, I apologize in advance for my code as I am new to Java/Struts.
Code:
########################################################################
# Action Class (use session scope bean for post back, sorting, etc.)
########################################################################
<action
attribute="maintainExchangeRates2Form"
="" input="show.maintain.exchangerates2" name="maintainExchangeRates2Form" parameter="methodToCall" path="/maintainExchangeRates2" scope="session" type="com.ehaci.struts.action.MaintainExchangeRates2Action" validate="false">
<forward name="addSuccess" path="/editExchangeRate.do?methodToCall=display">
<forward name="success" path="show.maintain.exchangerates2">
<forward name="failure" path="/maintainExchangeRates2.do?methodToCall=display">
########################################################################
# Associated Form Bean
########################################################################
<form-bean name="maintainExchangeRatesForm" type="com.ehaci.struts.form.MaintainExchangeRatesForm">
########################################################################
# Form Bean Class (key variable is the rates List, which is used by the grid)
########################################################################
package com.ehaci.struts.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.validator.ValidatorForm;
import org.apache.struts.action.ActionMapping;
import java.util.*;
import com.ioshq.comparator.*;
import org.apache.struts.util.MessageResources;
public class MaintainExchangeRates2Form extends ValidatorForm {
// --------------------------------------------------------- Instance Variables
private List rates;
// Sorting, etc...
private String txtCurrPage="1";
private String txtSortCol="agentProcessingMonth";
private String txtNextSortAscDesc="ASC";
private String txtCurrSortAscTrueFalse="true";
private String txtBaseAction="maintainExchangeRates2.do"; // Used by JavaScript Sorting
private String labelAgentProcessingMonth;
private String labelCurrRate;
private String labelComments;
private String newAgentProcessingMonth;
// --------------------------------------------------------- Methods
public MaintainExchangeRates2Form() {
// 02/05/06 - grid tag downloaded needed access to Message Bundle,
// couldn't figure out how to nest in grid tag,
// so had to look up and set in a variable.
// Would have liked to have code on JSP, but couldn't get to work.
MessageResources mResources = MessageResources.getMessageResources( "com.ehaci.struts.ApplicationResources" );
labelAgentProcessingMonth = mResources.getMessage("maintain.exchangerates.agent_processing_month");
labelCurrRate = mResources.getMessage("maintain.exchangerates.currency_rate");
labelComments = mResources.getMessage("maintain.exchangerates.comments");
}
public String getLabelAgentProcessingMonth() {
return labelAgentProcessingMonth;
}
public void setLabelAgentProcessingMonth(String labelAgentProcessingMonth) {
this.labelAgentProcessingMonth = labelAgentProcessingMonth;
}
public String getLabelComments() {
return labelComments;
}
public void setLabelComments(String labelComments) {
this.labelComments = labelComments;
}
public String getLabelCurrRate() {
return labelCurrRate;
}
public void setLabelCurrRate(String labelCurrRate) {
this.labelCurrRate = labelCurrRate;
}
public String getNewAgentProcessingMonth() {
return newAgentProcessingMonth;
}
public void setNewAgentProcessingMonth(String newAgentProcessingMonth) {
this.newAgentProcessingMonth = newAgentProcessingMonth;
}
public String getTxtCurrSortAscTrueFalse() {
return txtCurrSortAscTrueFalse;
}
public void setTxtCurrSortAscTrueFalse(String txtCurrSortAscTrueFalse) {
this.txtCurrSortAscTrueFalse = txtCurrSortAscTrueFalse;
}
public void sortRates() {
Comparator comparator;
comparator = new BeanPropertyComparator(this.txtSortCol);
Collections.sort(rates,comparator);
if (!this.txtNextSortAscDesc.equals("ASC")) {
Collections.reverse(rates);
// this sort is desc
this.setTxtCurrSortAscTrueFalse("false");
// Next Sort Will be ASC
this.txtNextSortAscDesc="ASC";
}
else {
// this sort is asc
this.setTxtCurrSortAscTrueFalse("true");
// next sort will be desc
this.txtNextSortAscDesc="DESC";
}
}
public List getRates() {
return rates;
}
public void setRates(List rates) {
this.rates = rates;
}
public String getTxtCurrPage() {
return txtCurrPage;
}
public void setTxtCurrPage(String txtCurrPage) {
this.txtCurrPage = txtCurrPage;
}
public String getTxtNextSortAscDesc() {
return txtNextSortAscDesc;
}
public void setTxtNextSortAscDesc(String txtNextSortAscDesc) {
this.txtNextSortAscDesc = txtNextSortAscDesc;
}
public String getTxtSortCol() {
return txtSortCol;
}
public void setTxtSortCol(String txtSortCol) {
this.txtSortCol = txtSortCol;
}
public String getTxtBaseAction() {
return txtBaseAction;
}
public void setTxtBaseAction(String txtBaseAction) {
this.txtBaseAction = txtBaseAction;
}
}
########################################################################
# Data Transfer object
########################################################################
package com.ehaci.business;
public class ExchangeRate extends EhaciBusinessBase {
private String agentProcessingMonth;
private double currRate;
private String comments;
public String getAgentProcessingMonth() {
return agentProcessingMonth;
}
public void setAgentProcessingMonth(String agentProcessingMonth) {
this.agentProcessingMonth = agentProcessingMonth;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public double getCurrRate() {
return currRate;
}
public void setCurrRate(double currRate) {
this.currRate = currRate;
}
}
########################################################################
# Action Class
########################################################################
package com.ehaci.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.actions.DispatchAction;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.ehaci.business.ExchangeRate;
import com.ehaci.constants.EhaciConstants;
import com.ehaci.dao.MaintainExchangeRatesDAO;
import com.ehaci.struts.form.MaintainExchangeRates2Form;
public class MaintainExchangeRates2Action extends DispatchAction {
// --------------------------------------------------------- Instance Variables
// --------------------------------------------------------- Methods
public ActionForward display(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
MaintainExchangeRates2Form maintainExchangeRates2Form = (MaintainExchangeRates2Form) form;
MaintainExchangeRatesDAO accessor = new MaintainExchangeRatesDAO();
try {
List list = accessor.getAllRates();
maintainExchangeRates2Form.setRates(list);
}
catch (Exception e) {}
return mapping.findForward(EhaciConstants.ACTION_SUCCESS);
}
public ActionForward sort(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
MaintainExchangeRates2Form maintainExchangeRates2Form = (MaintainExchangeRates2Form) form;
maintainExchangeRates2Form.sortRates();
return mapping.findForward(EhaciConstants.ACTION_SUCCESS);
}
public ActionForward page(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
// Do nothing, control handles paging
return mapping.findForward(EhaciConstants.ACTION_SUCCESS);
}
public ActionForward delete(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
ExchangeRate rate=null;
String key=null;
key = request.getParameter("agentProcessingMonth");
if (key == null || key == "" ) {
return mapping.findForward(EhaciConstants.ACTION_FAILURE);
}
else {
// Get our dataccessor...
MaintainExchangeRatesDAO accessor = new MaintainExchangeRatesDAO();
rate = null;
rate = accessor.getRate(key);
if (rate != null ) {
rate.freezeMe();
// use data accessor to delete
accessor.deleteRecord((ExchangeRate) rate.getFrozenData());
}
return this.display(mapping,form,request,response);
}
}
public ActionForward add(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
ExchangeRate rate=null;
String key=null;
key = request.getParameter("newAgentProcessingMonth");
//System.out.println("In add Action, key = "+key);
if (key == null || key == "" ) {
return mapping.findForward(EhaciConstants.ACTION_FAILURE);
}
else {
// Get our dataccessor...
MaintainExchangeRatesDAO accessor = new MaintainExchangeRatesDAO();
rate = new ExchangeRate();
rate.setAgentProcessingMonth(key);
rate.setCurrRate(1.00); // default
rate.setComments("");
// use data accessor to delete
accessor.addRecord(rate);
// Set the key for next operation
request.setAttribute("agentProcessingMonth", key);
//return this.display(mapping,form,request,response);
return mapping.findForward(EhaciConstants.ACTION_ADD_SUCCESS);
}
}
}
########################################################################
# JSP Page (tiles definition points to this page)
########################################################################
<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/datagrid.tld" prefix="grd" %>
<%@ page import="com.freeware.gridtag.*" %>
<%@ page import="java.util.List" %>
<%-- Get Vars out of message bundle to plug labels into grids --%>
<%-- 2/5/06 - WANTED TO THE FOLLOWING, BUT COULD NOT GET TO --%>
<%-- WORK, HAD TO MOVE BACK TO ACTION FORM SO I COULD MOVE ON!--%>
<%-- page import="org.apache.struts.util.MessageResources" --%>
<%-- MessageResources mResources = MessageResources.getMessageResources( "com.ehaci.struts.ApplicationResources" ); --%>
<%--String lbl1 = mResources.getMessage("maintain.exchangerates.agent_processing_month"); --%>
<%--String lbl2 = mResources.getMessage("maintain.exchangerates.currency_rate"); --%>
<%--String lbl3 = mResources.getMessage("maintain.exchangerates.comments"); --%>
<html:javascript formname="maintainExchangeRates2Form">
<html:form action="maintainExchangeRates2.do?methodToCall=add" onsubmit="return (validateMaintainExchangeRates2Form(this) && promptAdd(document.forms[0].newAgentProcessingMonth.value)) ">
<grd:dbgrid id="grdRates" name="grdRates" width="100" pagesize="15" currentpage="${maintainExchangeRates2Form.txtCurrPage}"
="" border="0" cellspacing="1" cellpadding="2" datamember="" datasource="${maintainExchangeRates2Form.rates}" cssclass="gridTable">
<grd:gridpager imgfirst="images/First.gif" imgprevious="images/Previous.gif"
="" imgnext="images/Next.gif" imglast="images/Last.gif">
<grd:gridsorter sortcolumn="${maintainExchangeRates2Form.txtSortCol}" sortascending="${maintainExchangeRates2Form.txtCurrSortAscTrueFalse}">
<grd:rownumcolumn headertext="#" width="5" halign="right">
<grd:imagecolumn headertext="" width="5" halign="center" imagesrc="images/Edit.gif"
="" linkurl="javascript:doEdit('{agentProcessingMonth}','editExchangeRate.do?methodToCall=display&agentProcessingMonth={agentProcessingMonth}')" imageborder="0" imagewidth="16" imageheight="16" altertext="Click to edit">
<grd:imagecolumn headertext="" width="5" halign="center" imagesrc="images/Delete.gif"
="" linkurl="javascript:doDelete('{agentProcessingMonth}','maintainExchangeRates2.do?methodToCall=delete&agentProcessingMonth={agentProcessingMonth}')" imageborder="0" imagewidth="16" imageheight="16" altertext="Click to delete">
<grd:textcolumn datafield="agentProcessingMonth" headertext="${maintainExchangeRates2Form.labelAgentProcessingMonth}" width="10" sortable="true">
<grd:numbercolumn datafield="currRate" dataformat="#.####" headertext="${maintainExchangeRates2Form.labelCurrRate}" width="25" sortable="true">
<grd:textcolumn datafield="comments" headertext="${maintainExchangeRates2Form.labelComments}" width="50" sortable="true">
<bean:message key="maintain.exchangerates.agent_processing_month">:
<html:text styleclass="gridRowOdd" property="newAgentProcessingMonth"><html:errors property="newAgentProcessingMonth">
<html:submit property="btnAdd" styleclass="gridRowOdd"><bean:message key="button.add">
<%-- Following are required for dbgrid.js, MUST BE IN YOUR FORM BEAN --%>
<html:hidden property="txtCurrPage">
<html:hidden property="txtSortCol">
<html:hidden property="txtNextSortAscDesc">
<html:hidden property="txtBaseAction">
|
|
|
|
|
Sorry, JSP tags were removed as I failed to click ignore HTML tags....
<%@ page language="java"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="/WEB-INF/datagrid.tld" prefix="grd" %>
<%@ page import="com.freeware.gridtag.*" %>
<%@ page import="java.util.List" %>
<link rel="stylesheet" href="<%=request.getContextPath()%>/styles/GridStyle.css" type="text/css">
<script language="javascript" src="<%=request.getContextPath()%>/scripts/dbgrid.js"></script>
<%-- Get Vars out of message bundle to plug labels into grids --%>
<%-- 2/5/06 - WANTED TO THE FOLLOWING, BUT COULD NOT GET TO --%>
<%-- WORK, HAD TO MOVE BACK TO ACTION FORM SO I COULD MOVE ON!--%>
<%-- page import="org.apache.struts.util.MessageResources" --%>
<%-- MessageResources mResources = MessageResources.getMessageResources( "com.ehaci.struts.ApplicationResources" ); --%>
<%--String lbl1 = mResources.getMessage("maintain.exchangerates.agent_processing_month"); --%>
<%--String lbl2 = mResources.getMessage("maintain.exchangerates.currency_rate"); --%>
<%--String lbl3 = mResources.getMessage("maintain.exchangerates.comments"); --%>
<html:javascript formName="maintainExchangeRates2Form" />
<html:form action="maintainExchangeRates2.do?methodToCall=add" onsubmit="return (validateMaintainExchangeRates2Form(this) && promptAdd(document.forms[0].newAgentProcessingMonth.value)) " >
<grd:dbgrid id="grdRates" name="grdRates" width="100" pageSize="15" currentPage="${maintainExchangeRates2Form.txtCurrPage}"
border="0" cellSpacing="1" cellPadding="2" dataMember="" dataSource="${maintainExchangeRates2Form.rates}" cssClass="gridTable">
<grd:gridpager imgFirst="images/First.gif" imgPrevious="images/Previous.gif"
imgNext="images/Next.gif" imgLast="images/Last.gif"></grd:gridpager>
<grd:gridsorter sortColumn="${maintainExchangeRates2Form.txtSortCol}" sortAscending="${maintainExchangeRates2Form.txtCurrSortAscTrueFalse}"></grd:gridsorter>
<grd:rownumcolumn headerText="#" width="5" HAlign="right"></grd:rownumcolumn>
<grd:imagecolumn headerText="" width="5" HAlign="center" imageSrc="images/Edit.gif"
linkUrl="javascript:doEdit('{agentProcessingMonth}','editExchangeRate.do?methodToCall=display&agentProcessingMonth={agentProcessingMonth}')" imageBorder="0"
imageWidth="16" imageHeight="16" alterText="Click to edit"/>
<grd:imagecolumn headerText="" width="5" HAlign="center" imageSrc="images/Delete.gif"
linkUrl="javascript:doDelete('{agentProcessingMonth}','maintainExchangeRates2.do?methodToCall=delete&agentProcessingMonth={agentProcessingMonth}')" imageBorder="0"
imageWidth="16" imageHeight="16" alterText="Click to delete"/>
<grd:textcolumn dataField="agentProcessingMonth" headerText="${maintainExchangeRates2Form.labelAgentProcessingMonth}" width="10" sortable="true"></grd:textcolumn>
<grd:numbercolumn dataField="currRate" dataFormat="#.####" headerText="${maintainExchangeRates2Form.labelCurrRate}" width="25" sortable="true"></grd:numbercolumn >
<grd:textcolumn dataField="comments" headerText="${maintainExchangeRates2Form.labelComments}" width="50" sortable="true"></grd:textcolumn>
</grd:dbgrid>
<BR>
<bean:message key="maintain.exchangerates.agent_processing_month" />:
<html:text styleClass="gridRowOdd" property="newAgentProcessingMonth"/><html:errors property="newAgentProcessingMonth"/>
<html:submit property="btnAdd" styleClass="gridRowOdd"><bean:message key="button.add" /></html:submit>
<%-- Following are required for dbgrid.js, MUST BE IN YOUR FORM BEAN --%>
<html:hidden property="txtCurrPage" />
<html:hidden property="txtSortCol" />
<html:hidden property="txtNextSortAscDesc" />
<html:hidden property="txtBaseAction" />
</html:form>
|
|
|
|
|
I tried deploying the demo without success, yet I've deployed many a .war files before.
Is there a README you can point me to ?
|
|
|
|
|