Talhah Mafawalla

Greenhorn
+ Follow
since Nov 05, 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
2
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 Talhah Mafawalla

Thanks Dennis and Paul,

I have found the solution to this problem by using the method suggested by Dennis, I have found that the JasperFillManager class has a method ".fillReport()" that excepts and InputStream as a paremeter, and I am happy to say that i have the report generated.

Thanks again for your input.

Talhah Mafawalla.
16 years ago
Hi to all,

I am having a problem that i have been working on for about a week now. I a have just started using jasper reports.

The problem is that when i am runing my application in Netbeans 5.5 IDE i have no problems providing the path to the .jrxml file which is

Though when the application is complied into a jar file with the .jrxml file inside the jar file aswell, i get the following error:

I have tried to give the path dynamically using the following code:

but I also get an error. I would like to know how to give a reference to a .jrxml file located inside a jar file.

Tanks in advance.

Talhah Mafawalla
16 years ago
Hi all,

I hope this is the right section to post this question. I was wandering if anyone might help me. I am trying to print a JTable and i also want to put a header on the page as well as a footer with the page number. Is there also a way to get a print dialog that asks for the printer and also i can set the page orientation.

Thanks in advance
Talhah Mafawalla
16 years ago
Hi amit,

Did you create a DSN before you ran the code.

To create a DSN called "TEST" do the following:
1. Click Start in windows and select run or open comand promt.
2. Type "odbcad32" and press enter.
3. When the "ODBC data source administrator" opens click on "Add".
4. In the window "Create new data source" select "Microsoft Access Driver (*.mdb)" then click finish
5. In the window "ODBC Microsoft access setup", type "TEST" into the "Data source name" text box.
6. Next click "Select" under "Database", then browse and select you Microsoft access databse and click "Ok".
7. Then click "Ok" on the "ODBC Microsoft access setup" window.
8. Then click "Ok" on the "ODBC data source administrator" window.
9. Re run the page.

I hope this is what you were looking for.
Thanks Adeel and Nelson,

I think i have got a solution by using a variable in the while loop to count the number of times it get executed, thus if the number is zero i displayed a "Record not found" message. Otherwise the table gets built.

Though Adeel would the reason you recommend not using scriptlets/Java code in JSPs and DB stuff in JSPs because of security reasons?

Should the database stuff go into a java class to get executed a then only return a result(e.g. I have a class that handles the database connection either for MySQL or Access by passing to it a string and it returns a Connection). Would this be what you are talking about?

Also what would "VO" and "TO" stand for. I have just started learning jsp and i am looking for good guidlines to follow (coding conventions etc.)

The code that i have produced now is as follows:


Sorry for posting so much code but i have made chages to various parts of the jsp file.

Thanks again for everyones help
Talhah Mafawalla

[ April 09, 2007: Message edited by: Talhah Mafawalla ]
[ April 09, 2007: Message edited by: Talhah Mafawalla ]
16 years ago
JSP
Hi Wilson,

Thanks very much for the help.

I was just wondering if you could explain why when i had my code in that catch statement and it printed the message the entire page above that catch code got over written and only the error message and the "Add New" <a> tag got displayed.

When i changed it to the following the page prints out correctly.



Thanks again for the help
Talhah Mafawalla
16 years ago
JSP
Hi Nitesh,

The error that i got using ex.getMessage() was:

[Microsoft][ODBC Driver Manager] Invalid cursor state
16 years ago
JSP
Hi,

After i have caught an error using try catch i would like to display that message on the same page in a div panel.

I was just wondering how would i call a div panel and display the message in it without clearing the rest of the page. Would i have to re-create the page in the java code?

The code is as follows:
16 years ago
JSP
Hi Nitesh Kant,

That was the problem i couldnt find a way to count the number of records in the record set. Though that would have made it easy.

I have solved the problem by using the following code which forces the compiler to throw an error when there is no records in the record set:
16 years ago
JSP
Hi

I seem to have a problem at which i have been working on for about five hours and cant seem to get to a solution.

This is what i am doing, i have a search field which queries a database and displays the results of its search in a table below it. The problem is that when i search for a non existent record i want to display an error message that says a record was not found.

I have tried the following:
1. Surrounded the code with a try catch which caught SQLExceptions, though when a non existent record was searched no error was caught.

2.I tried to somehow count the returned record count from the resultset and if the count was zero display the error, but had no luck there either

Here is the code:


I thank everyone in advance.

Thank you
Talhah Mafawalla
16 years ago
JSP
Thank you Sean and Craig. Atleast I got a reply from you guys. I have been looking for help on this for months.

Thank you guys again
Talhah Mafawalla
17 years ago
Hi,

I was wondering if anyone could help. I have been having problems with this for months now. I searched the internet and read a java book but got no direct help on what i am trying to do.

I have a JTable which has 5 columns, the last column is not editable and the first column when clicked opens a new JFrame. The second column has a combo box and the third and fourth columns have JTextFields in them which are formatted for currency.

What i am trying to do is that when i tab or press enter to go into the third and fourth fields i would like the focus to shift from the cell to the JTexField so that the caret is visible and the contents are highlighed.

Any help with this would be greatly appreciated.

Thanking you
Talhah Mafawalla
17 years ago
Hi

If annyone could help, I am trying to add a focus listener to cell so that when it gains focus by tabbing into ot or pressing enter and it gets selected i want the component (e.g JTextField) inside the cell to get focus.

I have had a long hard look at the JTable class, inside i know there is a protected inner class called AccessibleJTableCell inside which it has the method addFocusListener(). The problem is that i dont know how to access that class.

Please could annyone help.
Thanks in advance

Talhah Mafawalla
17 years ago
Thanks Brian for all the help. I am still learning java and hopefully will get a better understanding of how the language works. Thanks alot for all your input. Also i think i have solved the problems that i had and used the AbstractTableModel afterall.

Thanks again for the help.
Talhah Mafawalla
17 years ago
To Michael Dunn,

Thank you that was part of the solution this is what i actually did:

public int getRowCount() {
if(vData == null){
return 0;
}else{
return vData.size()/3;
}
}

This seems to work fine,though i had to divide by three because i intially wanted one row of data but it was repeating the one row two extra times. I think i am grasping the logic behind whats happening, thanks alot Michael.

To Brian Cole,

The reason for using DefaultTableModel is that when i initialy extended on the AbstractTableModel then changed it to DefaultTableModel the implemented methods were the same but i thought that DefaultTableModel would handle vectors better. Now that i have sat on this problem for almost a week i think both seems to work very similar only that DefaultTableModel does not execute the inheritant classes constructor first. I am still learning java and i am still trying to get my head around things. Though i think i will change back to AbstractTableModel

Thanks for all the help you guys.
Talhah Mafawalla
17 years ago