Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!

Shin Hashitani

Ranch Hand
+ Follow
since Dec 04, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Shin Hashitani

Hi everybody,
Windows 2000 JRun4 log4J1.2.6 JDK1.4.1

I am having trouble identifying Logger in jsp:
<%@ page import="org.apache.log4j.Logger" %>
Logger log4 = null;

log4 = Logger.getLogger(this.getClass());
log4.debug("testing log4j");
I tried the above code, and nothing comes out. In case of JSP, I believe the name of the class that would be generated depends on a kind of application server. In that case, getLogger(MyClass.class); is not a good way to define Logger.
But how do I find the name of the class at runtime? It seems that everyone is having no problem using Log4J except me.
Thank you

Shin Hashitani
Hi Jeroen,
I think using Action class just to forward to jsp is okay. At least you can hide the path of that jsp file.
But probably using
would be a better solution. By using this, you don't have to create an Action class. You can specify that behavior in struts-config.xml alone.

<action path="/saveSubscription" type="org.apache.struts.actions.ForwardAction" name="subscriptionForm" scope="request" input="/subscription.jsp" parameter="/path/to/processing/servlet">
Just like this.
[ January 12, 2003: Message edited by: Shin Hashitani ]
17 years ago
I checked criteria.toString()
SELECT magazine.MAGAZINE_ID, magazine.SITE, magazine.PUBLISHED, magazine.CREATED, magazine.LAST_MODIFIED, magazine.VISIBLE, magazine.DELETE FROM magazine WHERE magazine.PUBLISHED= IS NOT NULL AND magazine.SITE=10000 ORDER BY magazine.PUBLISHED DESC
this part is definetely wrong, and I think this is what is causing this problem.
So I guess using
add(MagazinePeer.PUBLISHED, Criteria.ISNOTNULL);
does not work. But in that case, why we have Criteria.ISNOTNULL to begin with?
And suggested mathod still gives me compile time error.
I am runnint out of time, and I don't want to leave this part like this. I am still looking for a solution. If you know something, please let me know.
Thank you
17 years ago
Hi everyone,
NULL is what confuses me. Especially when I deal with them in Torque.
What I thought first was:
Criteria.add(MagazinePeer.PUBLISHED, Criteria.ISNULL);
Well, this doesn't work. I get "Error near 'NULL'" or runtime error of that sort.
In Criteria how to tutorial:
criteria.add(MagazinePeer.PUBLISHED, (Object)"PUBLISH IS NULL", Criteria.CUSTOM);
This is what they suggest. So I trid that. Now the copmile doesn't go through.
"": Error #: 304 : method add is ambiguous. method add(java.lang.String, java.lang.Object, org.apache.torque.util.SqlEnum) class org.apache.torque.util.Criteria and method add(java.lang.String, java.lang.String, java.lang.Object) class org.apache.torque.util.Criteria exists. column 83, Row 12
(**The error message came out in Japanese, so it's my translation)

Removing (Object) casting does let me compile it, but it gives me the runtime error. SqlEnum is a package scoped object, so I cannot cast that, either.
But before that,
this must happen all the time if somebody try to set NULL value to Criteria object.
Do you know how to fix this?
It seems impossible and that can be a huge problem to me.
If you have any idea or suggestion, please let me know. I'd really appreciate it.
Thank you in advance.
17 years ago
I apologize for digging up an old thread.
I am still in the same project, and encountered an I-should've-thought-bout-this problem. I want to ask you how to manage this problem if you were me:
The basic technique is:
The form has a hidden element which is linked to a property in the action form.
onclick event handler calls a javascript function that will set a particular value to the hidden form.
A click of a certain button is traceable from action form, without depending on value property of the submit button.
A page can have a lot of form elements. And very often, espacially in server-side technology enabled system, the number of forms cannot be determined at compile time. So, using.
Is not a dependable way to access a particular form by javascript.
So, I thought
Is a better way to do it.

However, html:form tag does not allow me to set name of the form.
how do I manage this?
Or, how do you manage this if you were me?

I appreciate any comment or suggestion.
Thank you.
17 years ago
Sony's new "cocoon VCR server" in Japan has a web-based VCR record request feature as a service. (You can set time-record of you VCR from web.) This product came out last month.
The system uses Struts 1.0.
There are lots of form elements, and the session is hold through multiple forms, Struts made everything easy for the project team. They used one big ActionForm.
The system supports several web browsers, and three leading cell phone standards. In a case like this, Java-based solution is a pretty good one.
If they use Cocoon (jakarta Cocoon. Confusing, right.)for display, it might be even more excitng.
Well, they don't advertise the fact that they use Struts, but the system heavily depends on it.
Sorry I could only find the site in Japanese. But I hope you can get the feel of how it works.
[ December 08, 2002: Message edited by: Shin Hashitani ]
17 years ago
Hi Tanel,
Thanks for the reply.
Yes, I remember this tutorial. It was a long time ago, so I didn't remember much in detail. I sure don't remember the comment you mentioned. You gave me a new starting point.
From the tutorial:
Criteria crit = new Criteria();
crit.add( AuthorPeer.LAST_NAME, "Eddings" );
Vector v = AuthorPeer.doSelect( crit );
if ( v != null && v.size() > 0 )
de = (Author) v.elementAt(0);
Well, he actually uses last name of the author to get the inserted record, so this doesn't work. This is something I tried to avoid because, well, this is weird. And in my case, using one field won't be sufficient. I mean, in order to find a primary key, if I have to use lots of fields as a criteria to get it, what is a point of having the primary key at the first place? This I have to try Peer's doInsert method.
criteria = new Criteria();
criteria.add(MagazinePeer.SITE, magazine.getSite());
objectKey = MagazinePeer.doInsert(criteria);
primaryKey = Integer.parseInt(objectKey.getValue().toString());
I ended up doing like this.
This is pretty close to what Peer's doInsert method does, so I feel a little dumb, but this gives me the primary key. I was actually a little nervous if I can get the primary key in int by parseInt() method, but I sure did. So, key property in ObjectKey object contains the primary key in object format.
There might be a better way to do this (I sure hope there are), but this is one way to do it. In case somebody else encounter the same problem, I posted my solution. And I hope this not-setting-primary-key-after-save-method problem will be fixed as Tanel mentioned.
[ December 08, 2002: Message edited by: Shin Hashitani ]
[ December 08, 2002: Message edited by: Shin Hashitani ]
17 years ago
Eddie Izzard!
I've been waiting so long for his "Grolious" DVD to come out. I saw it once at my friend's home when I was in the states and loved it.
But practically nobody knows him here in Japan. Well, some people do but they think he is an actor.
"Cake or Death" bit is my favorite!
17 years ago
Struts 1.12b
PostgreSQL 7.2.3
Torque 3.0 rc-2
JDK 1.4.0

I am trying to use Torque for Struts application. The save() method of each torque class works fine.
In one situation, I have to create an entry first, then create multiple entires in another table with foreign keys to the primary key of the first entry. I can't find a good way to do it.
Magazine object (Contains magazine info)
Article object (each article inside of Magazine object, and has a foreign key mapped to the primary key of the magazine. Magazine class corresponding TorqueMagazine class, and Article class has a corresponding TorqueArticle class. The magazine object is contained in ActionForm as a bean.
Hi everyone,
save() method doesn't return the primary key when inserted. I didn't know this, so now I have a problem.
I get "foreign key integraton violation" when I call save method of torqueArticle. It says that magazine table doesn't contain the primary key that is referenced by a foreign key of the torqueArticle object.;
pageKey = actionForm.getMagazine().getMagazineID();
for(int i =0; i < actionForm.getMagazine().getArticle().size(); i++) {
Something like this.
And above code doesn't work after inserting a magazine entry. MagazineBeanHelper create torqueMagazine object, fill it with magazine object, and calls save() method . save method doesn't return the primary key, but I thought at least set the newly created primary key to the torqueMagazine object.
It didn't.
The only other way I can think of is to do "saving magazine", "getting that magazine right away", get the primary key of the magazine", "use the key to store each article objects". Or I have to use doInsert() of Peer class instead.
Then again,
how do I get the newly stored entry?? I can't get the primary key. The system is accessed concurrently by multiple users, so getting the latest torqueMagazine doesn't always work.
Or before that,
now I think that there must be a smarter way to do this!
Does anybody know??
I appreciate any suggestion or thought.
Thank you in advance.
[ December 05, 2002: Message edited by: Shin Hashitani ]
[ December 05, 2002: Message edited by: Shin Hashitani ]
17 years ago
Hi Bill,
It worked!!
It would have been a nightmare if I couldn't solve this part.
Thank you!!
17 years ago
"onclic" is a typo.
Somehow I coundn't post something with "onclick" in it.
17 years ago
Hi everybody,
In Ted Husted's Struts Tips site,
<html:hidden property="dispatch" value="error"/>
<SCRIPT>function set(target) {document.forms[0].dispatch.value=target;}</SCRIPT>
<html:submit onclic="set('save');">SAVE</html:submit>
<html:submit onclic="set('create');">SAVE AS NEW</html:submitl>
<html:submit onclic="set('delete);">DELETE</html:submit>
one part of the tutorial shows a way to use javascript to set value in ActionForm. Smart. I wanted to try the same thing and ran into a problem:
function set(target) {
document.forms[0].source.value = target;
<html:hidden property="source" value="notSet" />
<logic:iterate id="content" name="myBean" property="myProp" indexId="idx">
<html:submit onclic="set('<%=idx%>');" property="buttonName" value="another value" />

I want to use logic:iterate tag's indexId attribute to make that call.
The result is that everyting, including <% tag, shows up same as the source code. I tried converting indexId to int, again to String, and everything I can think of. Still no good result.
Is there any way to achieve this?
I appreciate your suggestions and comments.

Thank you.
17 years ago
Hi Ted,
thanks for the reply.
Okay, using the action mappings are one of the options that now I have.
doesn't that make struts-config large and hard to maintain as the system grows? For example, if I have 10 mappings and host 10 sites on the system, that would make 100 entries in the config file.
Is there a clearer way to handle this problem?
Any suggestions?
Thank you in advance.
17 years ago
Hi Adam,
thanks for the reply.

I have been digging around for a while, and I haven't able to find a solution that I am looking for. Also, I have learned a bit about Struts in general. I'll leave this problem alone for a while.
I was also surprised to find that using html:rewrite for images as Ted Husted suggests also shows the session id after the file name. (My friend tells me that it just should, but I am still having trouble understanding why, though.)
It's has been such a fun ride.
But it took me quite a while to get the general idea of Struts.
I will post here if I find something to solve this one.

Thank you,
17 years ago
Hi Moema,
I think this is what you are looking for.

Good luck!
17 years ago