General discussion

Locked

Java Forum

By MaryWeilage Editor ·
Welcome to the Java Forum. This is the place to post your Java questions, share your best techniques, develop your coding skills, and express your opinion on topics that impact IT development.

We also encourage you to post your comments about the Java TechMail.

If you haven't subscribed to the Java TechMail, there is no better time to take advantage of our free e-newsletter. Visit our e-newsletter subscription center to subscribe to this valuable TechMail today:
http://builder.com.com/techmails.jhtml?repID=u001

This conversation is currently closed to new comments.

29 total posts (Page 1 of 3)   01 | 02 | 03   Next
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Java TechMail

by MaryWeilage Editor In reply to Java Forum

Use inheritance to improve your Struts applications

The Mar. 6, 2003, Java TechMail discusses the use of a base action class to better implement Struts. Do you use Struts in your application development? Will this tip help improve your use of Struts?

This discussion question was derived from a Java TechMail. If you would like to receive Builder.com Java e-newsletters in your inbox twice a week, visit our e-newsletter subscription center to subscribe today:
http://builder.com.com/techmails.jhtml?repID=u001

Collapse -

Base action and dispatching

by thedew In reply to Java TechMail

A base action class is definately useful when all of your actions depend on the execute method, but what happens when many of your actions are doing dispatched execution?

The problem I run across is that my action classes define their own methods to call in their keyMethod map, so its base class would have no idea what method will be executed and nothing guarantees that the base action's execute method will ever be called.

Any suggestions for creating a useful base action class in this case?

Collapse -

Re: Base action and dispatching

by muzammil786 In reply to Base action and dispatchi ...

The important point is that you declare one abstract method in Base class which is to be implemented in all child action classes. Now if your action class needs to call other different methods, thus invoke all such methods in implemented abstruct method. Your Base class is not to check what business logic is implemented in child classes

Collapse -

Re: Base action and dispatching

by reassembler In reply to Re: Base action and dispa ...

i'm with shabaz. your abstract class should always call the one method that your subclass must define. if you want to map method calls, do it in the subclass. if your subclass does not override the struts action method, the your base classes method will always be called.

hope i'm not missing your point. let me know. if you have a code example you could send, that might clear things up.

dave

Collapse -

LookupDispatchAction

by thedew In reply to Re: Base action and dispa ...

This is a good idea to me, but I don't see how you could implement this using the structure provided by LookupDispatchAction (see http://jakarta.apache.org/struts/api/org/apache/struts/actions/LookupDispatchAction.html) because it's not my subclass's implemented abstract method that determines which method to call but this LookupDispatchAction's execute method.

Right now all my Action classes extend this base class:
------------------------------------------
public abstract class ActionBase extends
LookupDispatchAction {

protected Map getKeyMethodMap() {
return null;
}

public ActionForward execute(
ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {

// if there is no dispatch map, return the
// default execute method
if (getKeyMethodMap() == null) {
//DO USEFUL STUFF
return defaultExecute(mapping, form,
request, response);
} else {
return super.execute(mapping, form,
request, response);
}
}

public abstract ActionForward defaultExecute
(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception;
}
---------------------------------------
The only problem is defaultExecute only gets called when there is no dispatch map.

Collapse -

Do not use abstract classes for logging

by johnzoet In reply to Java TechMail

The email suggests to use an abstract base class for logging purposes.
I definitely do not recommend this method.
It is far better to centralize logging in a filter servlet.
That way you do not mix administrative and business logic.
The filter servlet can be changed independently from the base class which avoids possible problems in the production environment.

Collapse -

re: Do not use abstract classes for log

by reassembler In reply to Do not use abstract class ...

centralizing logging is definitely a good idea. i suggest using log4j's socket server and socket appender (wrong names, i'm sure), rather than writing a servlet to do it. there's also a buzz about using jms to centralize logging, but i've haven't tried that yet.

Collapse -

Java TechMail: BigInteger

by MaryWeilage Editor In reply to Java Forum

The Mar. 10, 2003, Java e-newsletter, discusses how to manipulate large bits with the BigInteger class. BigInteger allows you to manipulate numbers with more than 64 bits.

Have you used BigInteger? If so, tell us what your experience was like.

Collapse -

Build apps easier with the Ant tool

by Mark W. Kaelin Editor In reply to Java Forum

Make mundane dev tasks easier with Ant:

The March 13, Java TechMail discusses Ant as a Java build tool. Do you use Ant to build your Java applications? If not, what tools do you use? Why?

If you haven't subscribed to the Java TechMail, there is no better time to take advantage of our free e-newsletter. Visit our e-newsletter subscription center to subscribe to this valuable TechMail today:

http://builder.com.com/techmails.jhtml?repID=u001

Collapse -

A Bad Experience with Ant

by avia In reply to Build apps easier with th ...

Granted, I haven't looked at the latest version of "ant" -- I tried using versions 1.1, 1.2 and 1.3 (I think) and had a _bad_ experience. The documentation was terrible (in my opinion), backward compatibility was non-existent, there is no DTD (or schema or whatever) for the XML build files -- since they're not valid XML files, anyway -- and "ant" will happily print out "Build Successful", when it wasn't!
[Of-course, when it fails, and "ant" succeeds in figuring out it failed, it prints out, "there should have been error messages" -- that doesn't really assure me of the author's confidence in the tool!]

On the opening page of the "ant" Web site, they talk about cross-platform (i.e. non-UNIX) portability being an advantage of using "ant", but with linux and cygwin and the new MacOS, how many non-UNIX platforms are there?

So PLEASE convince me that "ant" is good!

Avi.

Back to Web Development Forum
29 total posts (Page 1 of 3)   01 | 02 | 03   Next

Related Discussions

Related Forums