Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Howard Ralston

Ranch Hand
+ Follow
since Jun 25, 2001
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 Howard Ralston

I think he meant that you don't pass the name of the image in the code you gave.



Might instead be:



Also, if your url-pattern is /download, shouldn't you use that instead of /DisableText?
[ May 24, 2006: Message edited by: Howard Ralston ]
12 years ago
Thanks, Mark.
No, we have no control as it will be used by the general public (those rascals). I did find this on IBM DeveloperWorks Retrofit your Web pages for wireless compatibility.
It has some good info provided we can follow the XHTML route.
12 years ago
Hello All,

We are developing a website for a large client with separate property sections. For instance, a property may have approximately 60 sub pages. Now we are asked to look into creating a scaled down mobile version of the same site, with approximately 10 sub pages per property.

My question is: What is the best way to approach this? Should we set up a subdomain such as mobile.mysite.com or set up a separate directory such as mysite.com/mobile/? Should we set up some kind of filter to convert the resultant HTML to WML? Currently we use Struts with Tiles on the front end.

Any suggestions would be appreciated.

Thanks,

Howard
12 years ago
One more followup:
When I tried to get a collection of items from the view I ran into a problem. Hibernate read 1 as the primary key and iterated the same row over again and again. I had to change the view to make report_id a unique composite of two rows. Then Hibernate would iterate through the entire resultset as needed. I did not use composite-id in the mapping, just left it as report_id.
Hi guys,

I figured it out.

SQL Server requires that you read the columns sequentially into your resultset. I had changed the mapping around and the get() statements were no longer sequential. If you use a tool such as Hibernate Synchronizer (like I did to create your java files, make sure that you keep the property elements in the same order.

If your columns are retrieved in the order:
1. id
2. myname
3. mydate
4. mycity

Your get statements must retrieve in the same order:
1. getId()
2. getMyname()
3. getMydate()
4. getMycity()

If not you will the the error I had.
Okay, I turned on more debugging and found the following. It looks as though Hibernate is pulling 1 record, closing the statment and resultset and then trying to read it again. Is that the case? If so, why? Shouldn't it bring back the full 27 records and then iterate through them?

Here is the new log:

Thanks Scott,

I tried that and also changed the variable "id" to match "groupId" and used the alias "r". Now I get a different error. It looks as though Hibernate is trying to run the query but generates an exception. The relevant error seems to be: "ResultSet can not re-read row data for column 3." See below.

Mapping:



Code:



Error:

Hello,

I am trying to use a named query but cannot get it to work.

The mapping element is:


I am calling it like this:



The pertinent section of the log looks like this:



Any ideas?

Thanks,

Howard
Thanks for the reply Scott. I just tried a variation and it worked fine. In my mapping file I created and id element with the name of "report_id" and the table name was the view "v_summary_report". All I did was modify the view to include "1 as report_view" to add that to the view. After that it seemed to work fine.

Howard
Howdy folks,

I have an existing app with an existing database. We have a report that is based upon a view with info from various tables. I am trying to generate the code to get the same report using Hibernate. The problem is that I cannot find any examples of how to do this. The docs don't really address the use of a view, only persistent classes based upon tables. Does anyone have a real example of the mapping class element and a snippet of code using the class based upon a view?

Thanks,

Howard
Thanks for the reply.
What I wanted to know is: how do I access any object in the session when I am coding a bean? If I have a Customer object stored in the session, how do I access it from a bean? I want to get values from the Customer object for comparison in the bean, then depending on the result, write a message in the jsp with the bean.
13 years ago
If you have a String object in a session that was put there earlier in an Action object, e.g. session.setAttribute("MyVariable", "MyString"), is it possible to retrieve "MyString" from the session in a non-form bean? I want to use the bean tag on a jsp but don't want to use code in the jsp to send the session to the bean, e.g. myBean.setSession(session).

Many thanks!
13 years ago
Thanks guys! I like the idea of using the database to track the sessions and
I will create a separate class to make the db calls.
Howard
15 years ago
Howdy folks,
I am trying to prevent multiple logins per user. I have done that
and it works fine, but the code does not take into account synchronization
of the code that adds and removes the username for each session.
I am hoping for some help with this part. Also, if you notice anything that
could improve the performance of the code, suggestions would be appreciated.
Here is a link to the four classes that are involved.
Code example
There is:
1. MultipleLoginServlet that creates the HashMap upon starting the web container.
2. LoginHashMap that adds and removes the username value with the session ID as the key.
3. LoginServlet that adds the username to the LoginHashMap object when the user logs in.
4. LoginSessionListener that removes the username from the LoginHashMap when the session ends.
Thanks,
Howard
15 years ago