Eric Nielsen

Ranch Hand
+ Follow
since Dec 14, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Eric Nielsen

I'm trying to understand how the collection values expressions (minelement, etc) are supposed to be used.

Here's a query that doesn't cause an error at server start up, but returns extra copies of multi-day competitions.

I would have prefered somerthing without the explicit join and simply chain in the WHERE, but it sounds like that is unsupported?
Ie. something like


I have code like


the generated URLs do not have the parameters (but the s:property debugging information shows that it is looping over the requested params properly)
The foo:bar pair is diagnostic to check if it was a retrieving from the map problem, but even it doesn't get added.

If I add includeParams="all" to the s:url, then one param (from the existing URL) is added, but none of the params from the loop are added.

What am I missing?

7 years ago
I recently upgraded from Struts 2.0.x + SmartURLs to Struts 2.2.1 + Convention plugin. However after upgrading all my static content is no longer being served. I read all the release notes along the way that I could find and nothing suggests that my old approach should have stopped working. I'm assuming my old system worked because of some (probably wrong) usage I was making with SmartURLs since that's the only change that touched the filters. Can anyone point out what else I need to change/tweak to get static content behaving again?

I'm using Maven as the build system.
static content is at


Here are my filters from web.xml


Here's the root node and contents of the struts.xml:
7 years ago
I'm trying to figure out the simple/ clean way to hook up freemarker ( or other template system ) to generate email bodies to send in a struts 2.1 based application.

I've seen some helper classes in Spring based apps that help deal with classpath issues but I haven't seen similar for struts 2. Do I just create a Configuration by hand an inject around?

Thanks
7 years ago
I've been struggling with a bidirectional list. Got something working, then realized I needed to flip which side controlled the relationship to allow the IndexColumn to be populated. I've tried following the example in the JPwH book but I get a "Repeated column in mapping for entity: com.ballroomregistrar.compinabox.online.data.Level column: position (should be mapped with insert="false" update="false")" exception. I don't see where the "repeated column" is coming from.

Here's my mapping.



Only accessors for the four members and constructors are omitted from the Level class. There is no member named "position" nor any sort of "virtual" member provided via accessors, etc.

There are numerous other collections hanging off the Competition entity, but none of them use an IndexColumn at present and none have a position field that could be leaking through.

I've also tried removing the various cascade settings (just to more exactly match the books example), but the same exception is thrown).

What am I overlooking?
Here's what I did for Struts 2.0.x + the SmartURLs plugin. I'm planning to migrate to Struts 2.1.x + Convention plugin plugin later today. (SmartURLs was a third party plugin, that became the base for the Convention plugin, so I expect them to be similar, but not exactly the same.)

in struts.xml


IIRC, the struts.action.extension can not be set to the empty string in 2.0.x without the SmartURLs filter replacement shown below in the web.xml. The action.packages just tells SmartURLs where to look for actions that aren't configured in struts.xml and the default.parent.package parameter assigns all discovered, non-overridden actions an xwork-package (ie not a java package).

in web.xml


I haven't been able to look for the updated documentation yet, but I would assume poking around looking for information on the Convention plugin would be the right starting point.
9 years ago
It depends greatly on the framework. For instance, it most modern action frameworks (Spring MVC, Struts 2, Stripes, etc) its very easy to unit test their building block pieces -- speaking in Struts 2 terms -- Actions, Interceptors, Converters are all very easily tested in isolation. With Struts 1 its much, much tougher... wouldn't say impossible, but probably not worth the effort.

If you're using jWebUnit or HttpUnit, you are NOT unit testing, nevermind the tools name. You are end-to-end, integration, acceptance testing.
9 years ago
Yes, that's definitely an approach I've found useful at times.
I think everyone will have their own rule of thumb, but to me:

If there is any information that belongs to the relationship and not to either end, that pushes me strongly to create the join entity.
(In your case, I say yes -- the due date is a property of the relationship, not the book nor the customer -- especially if you had to implement features regarding renewals as some libraries for instance provide progressive shorter renewal windows, or a maximum of one renewal. We would now have even more logic and state to hang off the LoanedBook class.)

If, when talking about the application your users would commonly use a name to refer to what the join entity represents,, that strongly pushes me to create the join entity.
(In this case "maybe" -- we don't talk about a "LoanedBook" in conversation. We might talk about the action of "Loaning" or "Checking Out", but I tend to avoid using a verb as a class. We might be able to name it the "DueDateSlip" which does have physical meaning to librarians... customers probably don't use that term, but probably would understand it. However it doesn't capture the "who" has the book aspect. And it doesn't track the state needed for renewal logic, if that's an issue.

Basically when working on a Domain Model, I would read up on Domain Driven Design. The books by Evans or Nilsson are wonderful at helping to explain these ideas.
I wouldn't consider that following the command pattern. As I would expect the service to have multiple methods. Normally in a command pattern each Command has one (sometimes two) public methods... normally a generic "execute" (and matching "undo" if two methods). So every operation would be its own class, not an exposed method on a service layer.

I would probably make the book.lendTo call also include the customer.assignBook call. Typically one side of a bidirectional relationship should take responsibility for updating both sides. Of course the service will still need to invoke the save on both daos (unless your persistence provider provides transitive persistence). This is the type of place where you almost want the "customer.assignBook" to be "private" to everyone aside from Book. sorta like C++'s friend methods, but that doesn't exist in Java.

Other possible refinements...
a) introduce a "LoanedBook" class that holds a Book, a Customer, and the return date, customer to it. Convert the book to a purely immutable class. Now Book is perfectly safe to return to any client code... You won't be able to ask a Book who has it -- you'll have to see "for this book, is there a checkout, if so, who has it?"

b) the constructor for LoanedBook, or the factory method returning a LoanedBook, would now contain all the logic about when a checkout is allowed, and what duration to set for the return. To me this would seem much cleaner than embedding that within the book, and the customer.
I would say it depends on how separate your client and your server are and how well the service implements a complete Domain Model.

It sounds like in your example you have a rather fine grained object model in the service, with some business logic living in the objects. However you have the service itself providing the transaction assurances needed. To me this would be a sign that either
a) the service layer isn't implementing a complete Domain Model
or
b) the client and service have legitimately different Domain Models

If your client and service are remote and highly decoupled, then I would guess (b) is more likely. Which, to me, might lead to needing some form of domain translating -- either DTOS, or an adapter, or a facade. If both sides share the same business logic, but not the same transactional nature, perhaps look at making the returned objects a read-only variant of the base class.

In the case of (a) I would expect that the client and the service are running within the same VM. If there are operations that always need to be paired with other updates, then the public API should expose something that does both things, and hide the lower level modifiers. Or if the lower level updates are sometimes used in isolation, and you're only worried about sometimes needing to wrap changes in transactions, look into the Command pattern for example to wrap these combined operations within a transaction.
OK, I've tried reformulating it to use straight maps and not a functional lookup. I've tried both OGNL and regular EL notations. None of them seem to work -- in all cases the function backing the map property is not invoked. I changed the logging from INFO to DEBUG, but nothing jumps out at me.

What should I be looking for in the log to see why the function isn't getting invoked? What else should I try?
9 years ago
I'm working on something a little bit like a data grid. However, while the current display is tabular, the data backing it isn't. As a result I can't use straight map notation to access the values to display.

The relevant portion of the jsp looks like


The action looks like:

EscursionBase implements ActionSupport; the jsp shown before is hooked up to the INPUT result of the action.

The line preceding the <!-- 1 --> works properly, so I thought I knew how to call functions with parameters in OGNL. The line around <!-- 2--> does not work. The breakpoint just inside the function is not hit. However there are no errors in the log. What am I missing?
9 years ago
I'm running into some errors when trying to hang supplementary associations off of a join entity.


Ie StudioCompetition is a join entity that replaces a direct M:M between Affiliation and Competition that provides a place to hang additional qualifies of the association.

I can't seem to figure out how to allow hook up the extra associations -- I get errors regarding the number of columns in the foreign key.

My current setup looks like:

which yields an error like:


Earlier I had the association on the StudioSessionPrice named "affiliation" of Type Affiliation... so it wasn't really bi-directional (more of a loop). Which fails with a similar error message -- different wording, but same general intent -- wrong number of columns.. That error made sense since I had the mapped by of something with a two column PK mapped by a single column/wrong type. So I switched to the code shown above.

Is there a way to back the supplementary association work? Or do I need to lose the compound primary key, add an artificial key to the join table and just treat it like a regular entity?
[ December 25, 2008: Message edited by: Eric Nielsen ]
Sounds like you want to
a) find out how many full packages the purchases qualifies for
b) multiply the number of full package by the package prince
c) add on the product of the unit price and the remainder

div & mod will be your friend....
9 years ago