Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Alex Serna

Ranch Hand
+ Follow
since Sep 18, 2009
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alex Serna

Thank you. That's what I ended up doing. I ended building the query string and avoiding parameter substitution.

I guess that in this case is fine because I'm not using any external input data and the view name is generated following some convention stuff.

I'm still curious why parameter substitution doesn't work in this case though....
Hi,

I'm having trouble with parameter substitution in Hibernate.

I'm using Hibernate 3.6.4-FINAL, Oracle Database 10g Express and the ojdbc14.jar driver.

When I execute this code:



I get the following exception. I have tried with setParameter("viewA", "empleados) and with positional parameter and none work. The query will succeed if I manually replace the select string and I don't use parameters.



From the log, it's like if Hibernate was trying to execute the query before the parameter substitution...

Any ideas?
Thanks for the response,

My interceptor stack is the te paramsPrepareParamsStack from the struts-defaul.xml with a minor modification, a interceptor I created for managing transactions with Hibernate.



I posted here http://pastebin.com/XJ8tv1Pn the complete stack.

I agree that all properties files are read once, but what does that have to do with populating the Java properties with the http parameters?

8 years ago
Thank you for the response. So if I have a component object of the same class as the the main class, that means that from the main class I can have access to all the component object's properties even if they are private. Right?
8 years ago
I'm using the paramsPrepareParams interceptor stack and I get an OgnlException whenever I submit the following form:



Here is the code for the corresponding Action:

And here is the code for the Model class which has an Address component class which is a JavaBean with all its getters and setters:



This is the exception I get:

11:06:26,075 WARN OgnlValueStack:60 - Error setting expression 'address.town' with value '[Ljava.lang.String;@521e9ffa'
ognl.OgnlException: target is null for setProperty(null, "town", [Ljava.lang.String;@521e9ffa)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2239)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
...

I get this same exception only for the properties in the Address class, the Shop's properties are fine. Despite the exceptions, the Address http parameters get transfered to the corresponding properties in the Java side and the application works fine. If I remove the firts params interceptor I won't get any exceptions.

I think that the first params interceptor is trying to set the Address.town property but it can't find it. To my understanding the Shop object (which has an Address component) already exists and get's it's name property setted without complaining. Why is not so with the Address properties?
8 years ago
Hello,

My java skills have gotten a little rusty... could anyone please tell me why I can access the property "text" which is marked private from within the equals method? If the object "other" is a different object, shouldn't I be using an accessor method to access it's private properties?



Thanks.
8 years ago
Thanks for you response David!

You are right, a blank field in the form is a request paramter with an empty string, not null. But my question is, where does this convertion from request parameter to Integer happens and how can I change that behavior so that I don't end up with 0.

I could achieve my goal with javascript by checking if that field is blank and assigning it a negative value onsubmit, but I wonder if there is a more elegant way to do it with struts...
10 years ago
Hi everyone,

I don't understand the way struts treats the ActionForm bean in Struts 1.3. This is how it goes...

I have a <html:form action="/myaction.do"><html:text property="myinteger"/></html:form>. I understand that this creates a new ActionForm bean with a type and a scope specified in struts-config.xml if the bean doesn't already exist.

The ActionForm bean I'm using has an Integer attribute which I want to have value -1 if no value was introduced in the form.

The first time I present the jsp page that has the <html:form> nothing appears in that <html:text property="myinteger"/> as I expect because the ActionForm bean has just been created and that Integer property has a default value of null.
My problem is that in my MyAction class, the first time I get my AtionForm subclass something(this is what I'm trying to find out) has assigned a default value of 0 to my Integer property which I was expecting to still be null.

I tried to prevent this by chaning the myinteger setter in my ActionForm subclass to:


but when debugging the setter method already comes with a 0.

Thanks!


10 years ago
Ok, I'll just think about it as something it will happen at request time...

Thank you Ankit!
Thank you Ankit,

Still, to me translation error makes sense, but an Exception at request time... let's say our jsp was loaded on startup... first it would be translated and after that compiled(no request would have come yet, I think this isn't considered request time yet). IMO this wouldn't make it to the first request, it would fail at compilation time.

What do you think?


I might be wrong but to my understanding when the jsp is translated it will generate a code like



and since a no-arg constructor doesn't exist, the code won't compile. How can that cause a RunTimeException?
I see what you mean... Thanks for the explanation! BUT... JspContext only gives you acces to the "out" implicit jsp object. It's PageContext the one that gives you access to the rest of implicit objects. I read somewhere that you can cast that JspContext to PageContext in order to get the rest of objects(i.e. ServletContext), but I think it said that this wasn't part of the specs and it depends on the Container being used... anyone could clarify this please?
Thank you for your response, I'll follow your advice....
Hi,

Congratulations!!! I also bought Whizlab's mock exams so far I have scored 64%, 81% and 70%. I'm wondering how different difficulty is from the real exam... Did you find the real exam easier than Whizlab's? How did you do on Whizlab's compared to the real exam?

Thanks!