Lance Hill

Greenhorn
+ Follow
since Oct 13, 2004
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 Lance Hill

In the SwingSet2 demo, they have a toolbar that lets you choose which demo to display by clicking on any of the toolbar buttons. If I take the demo out of the tabbedPane and put it directly in the content panel, clicking on the toolbar buttons does not immediately take you to the new view. One click removes the previous view and partially redraws the screen with the new view, while the second click finishes redrawing the screen with the new view.

It would be greatly appreciated if someone could provide an example (or point me to one) of how to do this so only one click is required to replace the current view with the selected one.
18 years ago
I am trying to implement the ability to change between screens in my application. For example, you may view a calendar screen and click on a button to go to a "add new calendar entry" screen.

The SwingSet2 demo lets you click on a toolbar button and it loads and displays a new screen with the demo you selected. The only problem is when I try to load the demo directly into the demoPanel, rather than into a tabbed panel, one click on the toolbar button partially redraws the screen and a second click finishes the transition.

I do not understand why the behaviour changes and trying to trace through the code, it appears to me as if nothing different happens, other than it requires two passes through the code to make the new screen visible unless it is loaded into the tabbed pane. Is there something going on in the tabbed pane I am missing?

Can anyone please explain what is going on with this, or point me to an example of how to switch between different views in repsonse to a menu selection or button click?
18 years ago
Ah, I believe I found my problem. There are two files used: core.jar and runtime.jar. Core.jar contains most, but not all of the Java API packages (java.sql.* being a notable exclusion). In order to include java.sql, you have to ensure the runtime.jar (not just core.jar)is in your build path.
18 years ago
I cannot find information on what jar/library contains the java.sql package. If someone could explain how to add this to my build path in RAD (formerly WSAD).

Thank you.
18 years ago
I have found a few good examples of how to build a web service that returns a simple string to a client, but I am hoping to be able to return a series of values to be used for a drop down list, or a document. Can someone please provide me some suggested resources for this?

Thank you.
18 years ago
I am trying to upload a pdf to the server's file system. I seem to be able to upload the file, but it is incomplete.

Once it is on the server, I would like to use an action to find the pdf and display it to the browser. This also seems to break the file. If I put a good pdf in place on the server, when I stream it to the browser, I get an error that the file is damaged.

When I look at the file after it is uploaded, I can see that it is not the complete file, so I suspect something is going wrong when I am reading the file in.

Any advice on how to ensure I get the entire (and unbroken) file would be appreciated. Any examples of better or easier ways to do this would be even more appreciated.

Code follows.

File Upload Action:

View File Action
19 years ago
Test that you are actually returning a List and not a null from your allStatuses() call.
19 years ago
Is there some way to control the use of the errors.header and errors.footer elements when using the html:errors tag?

I have both validation and runtime exceptions and would like to format them differently. In the case where I am rendering runtime exceptions, I do not want to use ul and li to display them as there will likely only be one error to display. I apologize if this question has been asked and answered a few times already, but I only find posts on how to show the error within the header and footer.
19 years ago
I had Hibernate 1.2 working okay in a simple junit test. Now I am trying to get it working in an simple Struts application. I have two questions:

1. Is is now required to provide a hibernate.cfg.xml file? Whenever I try to run a new test with the 2.1 version of Hibernate, I get the following error:
net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found

2. Where do I put the hibernate.properties and hibernate.cfg.xml files? I thought that putting them into the WEB-INF/classes folder would work, but I am hoping someone can confirm.
Paul: You give me way too much credit. The only thing I am confident about is that the fault lies with me and that it is a really silly oversight I am not able to spot (honey, have you seen my socks?). The debugger is a good idea, as the System.out technique is not helping. Perhaps it is time for me to evolve beyond text editor as IDE.
pascal: In my original post, I included an extract of the code including the following two lines:

private static final int departmentId = 444;
...
department.setDepartmentId(departmentId);

Are you suggesting this is not enough to assign the pk? If so, what else do I need to do to assign this value?

paul: I was thinking about the "type" issue myself, but could not see how that would cause this. I will try it out anyway just to rule it out.

All the examples I have looked at show the sql output as having the parameters in place in the query (i.e. the substitution has taken place already), rather than the prepared statement, so this is where some of my confusion originates. When I do this with jdbc/sql, even when I use a prepared statement, after making the substitutions (e.g. pstmt.setInt(1,444)), if I print out the query, I see the query with the inserted parameter values which is great for finding why queries do not work as expected. At this point, I strongly suspect that no parameter substition is occurring, but cannot see a way to confirm my suspicion.
Hmmm. So if the test fails because the insert is attempting to insert a record full of null values e.g.:

([ERROR] JDBCExceptionReporter - -[IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=3, COLNO=4" is not allowed. SQLSTATE=23502)

and assuming you are correct that the "hibernate.show_sql = true" configuration only shows the prepared statement being used, rather than the actual query being executed, what are my options for determining where the error is occurring and for seeing what query is actually being sent to the db?
The unit test fails prior to performing the commit since the database will not allow a null in the pk column. I assumed that the insert statement would actually include the values to be inserted. So instead of "insert into table(departmentId,name,city,state) values(?,?,?,?)", I thought it should read "insert into table(departmentId,name,city,state) values ( 444, 'Some Name', 'Some City', 'Some State')". Is this not the case?
I am trying to run a junit test with Hibernate. When the session.save() method runs, it does not seem to find the values I have assigned to the parameters to be stored. For example:

From test class:
<snip>
private static final int departmentId = 444;
department = new Department();
department.setCity("City");
department.setState("State");
department.setName("Department Name");
department.setDepartmentId(departmentId);
session.save(department);
</snip>

mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
<class name="Department" table="department">

<id name="departmentId" column="DepartmentId">
<generator class="assigned"/>
</id>

<property name="city" column="City"/>
<property name="name" column="DepartmentName"/>
<property name="state" column="State"/>
</class>

</hibernate-mapping>

I verified the object is fully populated, but when I look at the sql Hibernate is generating, I get:
Hibernate: insert into department ( City, DepartmentName, State, DepartmentId ) values ( ?, ?, ?, ? )

It looks to me like the mapping is not working correctly, but I cannot see anything wrong.

Help/suggestions appreciated.