Kaiser Lautern

Greenhorn
+ Follow
since May 11, 2005
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 Kaiser Lautern

I do not feel comfortable either. Especially because it makes no harm at all to repeat the instance variable in the sub-class but adds a lot to the readability of the code.

Thank you guys for the enriching responses. You're aces.

Cesar

Originally posted by Ernest Friedman-Hill:
This design makes me vaguely uncomfortable, and I think you feel the same way, or you wouldn't have written. This is one of those examples where extending a concrete class -- as opposed to extending an abstract one or implementing an interface -- leads you to write questionable code.

18 years ago
Hi,

I wonder, in the example below, where does the method from a superclass returns its output (a collection):



* why is it not necessary to attribute the superclass output to a variable, like below:

childrenfeatures = super.getChildrenFeatures(object);

Thanks for any help.

Kaiser
18 years ago
Sure. You can configure your application in different modules and then switch among them using the SwitchAction. you can find more about it in http://struts.apache.org/struts-core/userGuide/configuration.html (item 5.3)

Kaiser
18 years ago
Hi, folks,

Can anybody explain why this iterate tag is not iterating?
It is showing only the first string of the array.

This is the action code:


and this is the JSP:



Thank you.

Kaiser
18 years ago
Far from being an authoritative answer, I'll give only my impressions on this subject. If I am wrong, please anybody correct me.

1) I'd say that an exception declared as global will be caught by Struts independently of which action (or business logic) it was fired in; declared inside an action, only this specific action would treat (pass the control to the handler);

2)scope here is only the context used to look for the ActionError object, and I think we can use request scope in both global and local exceptions.

3) Exceptions have the "key" parameter that you can use to send a message to the view. But you can always use ActionError. Of course that if all you need is to to send messages to the jsp (without any other more elaborate processing) maybe you could get along without exceptions in the first place and use only ActionError (or ActionMessage).

4) this is the "declarative" way of treating exceptions in struts. So it spares you from writing try/catch blocks. So you should choose one way: either declare your exceptions in the struts-config or write explicit code (try/catch) in in your actions.

Hope it helps and please tell me if there is any false reasoning.

Kaiser

Originally posted by Artemesia Lakener:
1. what's the difference between <global-exception> and "local exception" (defined inside the <action> tag) ? Doesn't <global-exception> belong to some Actions ? Are they the exceptions that are *not* handled by Action ?

2. For <global-exception> should I always define the scope to "session" ? I guess "scope=request" won't work because it won't carry it all the way down. Right ?

3. If an exception is declared in the struts-config.xml, do I still have to write code like "ActionErrors erros = new ActionError(..); errors.add(new ..)" kind stuff ?

4. Is it true that if an exception IS caught and handled specifically in an Action, then it should *not* be declared in struts-config.xml any more (no matter global or local exception) ?

18 years ago
Thanks Merril,

That's exactly what was missing in my tld to make it work.

Kaiser
18 years ago
Hi, people,

Maybe this is a recurring question but I didn't manage to find the right keywords, so I'm gonna (re)post it.

I learned that custom tags don't accept other tags as their attribute values. So I can't write something like:

<myTag rocess att1='<bean:write name="att1id"/>'
att2='<bean:write name="att2id"/>'
att3 ='<bean:write name="att3id"/>'
/>
Is that correct?

The problem is that I changed the bean:write tags above to scripting variables (like <%=att1id%> but the tag handler is still getting the string "<%=att1id%>" instead of the content of the string attribute (like the parser is not parsing).

Can anybody help me?

Thanks in advance,

Kaiser
18 years ago
Hi, Merrill,

In fact I was using UTF-8 encoding, but it seems to change Latin-1 characters. On the other hand, it worked perfectly well with iso-8859-1.

Thanks,

Cesar

Originally posted by Merrill Higginson:
I encountered a similar problem a while back with French characters being displayed improperly. In my case, I was able to fix it by changing the <meta> tag in the header. Here is an example:

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

Just make sure that the charset is one that supports Brazilian Portuguese.

18 years ago
Hi,

I have an application that works well in English, but fails in Brazilian Portuguese. The problem is that I am comparing resource bundle content gathered in 2 different ways, as below:



Using the good old System.out.println, I see that these two methods in fact present different outputs for the Brazilian word "Pr�ximo" (for the curious, "next" in English):

bean:message - Pr├│ximo
messages.getMessage - Pr�ximo

So, does anybody know what should I do to make it work?

Thanks.

Kaiser
18 years ago
Hi, everybody,

I'd like to know if there are best practices (and goog examples) of generating aan xml file from data collected from html forms. Of course I can always "manually" generate xml elements from corresponding input fields in the form, but I was just wondering if there is any clever way of doing this.

Thanks

Kaiser




Yes. If you want to pass some values, always use submit in some sort of way.



Just to clarify one doubt of mine: the answer for this is the "submit" or the POST method? I mean, if I use a form/submit with a GET method instead, will parameters be sent too? I read once (don't remember where) that you can only send parameters to an ACTION using POST (which you can't do via links).

Kaiser
18 years ago
Hi Mallika,

Thanks for your answer.



In your jsp page, the tag declaration should be
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>



Well, the URI attribute is just a logical name and as such I can choose anything I want, I suppose, as long as I use the same name in the web.xml, where I'm going to map it to an absolute location. So why not a big URL?



The declaration in web.xml points to your local copy of the struts-bean.tld, and these tld files are placed in <web-root>/WEB-INF directory.



Yes. That's what I thought too, but this example I took from a full fledged struts app called struts-resume, which was supposed to work without much effort. And its web.xml does not include the taglib mapping...

Kaiser
18 years ago
Hi, folks,

Can anybody please tell me what is exactly the meaning of this message:

org.apache.jasper.JasperException: /index.jsp(0,0) This absolute uri (http://struts.apache.org/tags-bean) cannot be resolved in either web.xml or the jar files deployed with this application.

The .jsp declares the taglig as follows:

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>

It is the application struts-resum�. It originally used the
http://jakarta.apache.org/struts/tags-bean uri. I changed to the new one, but the error persists.

Kaiser
18 years ago
Thanks fr your answer Tim. I went and checked the Digester API. In fact the answer is in the line:


It calls the method addUser on the parent element (position top-1 in the stack and in this case, the servlet itself). And the addUser method in the servlet does the actual job:



Kaiser
18 years ago
Hi all,

I'm trying to understand the servlet code below, which is supposed to read the data from an xml file and load it to a hashtable. However, I couldn't figure out exactly at what time has the hashtable been populated.



I don't know the Digester API, but it seems that all it does is to populate the User and Subscription DTO's. Next, in the servlet's init() method (where load() is called) it's assumed that the hashtable is already populated:



Thanks,


Kaiser
18 years ago