Lalit Vora

Ranch Hand
+ Follow
since Jun 22, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lalit Vora

will this work for struts tag library? I am using
<html:submit\> right now

whats alt for?

please guide me
17 years ago
Hi,

can anyone tell me how to insert image instead submit button so that when i click on it it works same as submit button in struts?

Thanks
17 years ago
yes i have that in index.jsp

i have two message resources file one in src--java folder
other in classes--java folder
where to keep my message resource property file?

why it came like // line errors.add..... deprecated?
am i doing anything wrong in using other method? that is AddErrorMessage line below // line
in argument or so?

Please guide me
17 years ago
Hi All,
I am not getting error message displayed in my jsp. Yes if i am not entering correct date its not moving ahead but not showing me message.


I want to do validation in lookupform My lookup form and message resource property file is as under. I commented following line because It says this method is deprecated
//errors.add("Recdt", new ActionError("error.recdt"));

But it has following method
errors.add("Report Name", new ActionMessage("error.repname")); Here i am not sure in this method parameters are right or not. please suggest me. Where to keep my message resource property file. I was able to run with deprecated method before when i used myeclipse j2ee project and added struts library.

Below is my files please guide me


****************LookupForm.java**************

public class LookupForm extends ActionForm

{

private String reptype = null;
public String getReptype()
{
return (this.reptype);
}
public void setReptype(String reptype)
{
this.reptype = reptype;
}


private String repname = null;
public String getRepname() {
return (this.repname);
}
public void setRepname(String repname) {
this.repname = repname;
}

private String recdt = null;
public String getRecdt() {
return (this.recdt);
}
public void setRecdt(String recdt) {
this.recdt = recdt;
}




public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// Log the forms data
servlet.log("Reptype:" + reptype);
servlet.log("Repname:" + repname);
servlet.log("Recdt:" + recdt);

// Check for mandatory data
ActionErrors errors = new ActionErrors();

if (repname == null || repname.equals("") || repname.equals("one")) {
//errors.add("Report Type", new ActionError("error.reptype"));
errors.add("Report Type",new ActionMessage("error.reptype"));

}

if (reptype == null || reptype.equals("")) {
//errors.add("Report Name", new ActionError("error.repname"));
errors.add("Report Name", new ActionMessage("error.repname"));
}

int a;
String dateFormat = "MM/dd/yyyy";
int dateFormatLength = dateFormat.length();
try {

if (recdt.length() != dateFormatLength)
throw new Exception();

else
{
SimpleDateFormat format = new SimpleDateFormat(dateFormat);
format.setLenient(false);
Date theDate = new Date();
theDate = format.parse(recdt);
a =0;
System.out.println("valid date" +a);
}
}

catch(Exception e)
{

a = 1;
System.out.println("invalid date" +a);
if (a==1)
{
//errors.add("Recdt", new ActionError("error.recdt"));
errors.add("Recdt", new ActionMessage("error.recdt"));

}

}


*************************messageresouce.property*************

errors.header=<h4>Validation Error(s)</h4><ul>
errors.footer=</ul><hr>

error.reptype=<li>Please Select Report Type
error.repname=<li>Please Select Report Name
error.recdt=<li>Please Enter Date in mm/dd/yyyy format


I have <message-resources parameter="MessageResources" />

</struts-config> mentioned in strutsd config.



Thank you very much
Lalit
17 years ago
Hi Merrill

Thanks alot its working now
17 years ago
Hi,

can someone guide me please how to compare date i.e user inputed date with system date.

I have user inputted date in mm/dd/yyyy formate and i have default date as systemdate-1. Both i have using simpledate format.
I want to compare that user input date should not be greater than systemdate -1 I have system-1 date generated also. I dont know how to compare them. Please some one can help me with that.

Thank you very much
Lalit
17 years ago
Hi,

can anyone guide me please how to convert secs in duration field in resultset to display as mm:ss

Example. I am getting duration as 180 i want to show in report as 03:00

Thanks
17 years ago
Hi Paul,

Can explain in more simpler way i am not getting it. How will i get my actual value from resultset like i should get price as 26.97 instead this value. How to display then original value so that i can display it in report?

Please guide me

Thanks
17 years ago
Hi Merrill,

Thanks I will try that for showing to user. Code is running now. Thank you very much for your support.

I also want to know how to creat log and whats use of it.Any link or idea?

Thanks
Lalit
17 years ago
Hi when i run following code

String N= "abc";
ResultSet rset2 = stmt.executeQuery("select price from stock where symbol='"+N+"'");
System.out.println("value is "+rset2);

i get error oracle.jdbc.driver.OracleResultSetImpl@2c84d9

But query works for simple statement select * from stocks;
Any idea please guide me.
Thanks
Lalit
17 years ago
Hi ,
I forgot to ask will there be any issue if i am getting csv in same way and displaying to user
17 years ago
Hi Merrill,

I think i am able to write resultset to csv file. I have one problem. Below is my code

ResultSet rset = stmt.executeQuery("select * from stock");
ResultSet r1= rset;
try{
BufferedWriter out = new BufferedWriter(new FileWriter("C:\\j2sdk1.4.2\\demo\\applets\\newfile.csv"));
out.write("Name,Sex,value"+"\n");
while (rset.next())
{
System.out.println (r1.getString(1)); // Print col 1

System.out.println ("Entered");

This works //out.write(r1.getString(1));
*************************out.write(r1.getString(1),"M, 100.5"+"\n");
//out.close();
System.out.println ("Exit");
}
out.close();
}
catch (IOException e) { }

stmt.close();

I am getting error in line with * can not resolve symbol in bufferwriterclass out.write(.......)
^
Above that line is working and i can save result in csvfile. So can u guide me with it. Also how to return user url for this file? so that they can cleck and see report in Excel. Please guide me

Thanks
Lalit
17 years ago
Hi James, I am not getting exactly what you are trying to suggest. I have resultset with me through query. Now i want that when user selects criteria from index.jsp like reportname and date and clicks on submit button. It should return URL like report1.csv and when user click on it it should open in excel or notepad. Now i am not getting what to do once i have result set from database. I am developing struts application. I am looking for that code. After i have result in resultset once i fire query how to return this URL and how to write result in result set

If you can guide me i will be really thankful. I am not moving forward once i have data in resultset.

Thanks again

Lalit
17 years ago
Which classes will be useful to write to csv file? Do u have simple example so that i can understand in much better way? Please help me with it

Thanks
17 years ago
Hi All.
I want to generate reports. I am using struts. I want that I store result in CSV file and return url of csv so that when user clicks on url if he has excel report will open in excel otherwise in notepad. I dont want to generate report in jsp. So when user selects criteria and clicks on submit it will return url of csv and user can click on that url to open report in excel. I have resultset with me.
Can anyone guide me please

Thanks
Lalit
17 years ago