Then it hit me this morning. Since we just want to change the flow of the app, we just had to create another action in the struts-config.xml file. 2 lines of xml and we had implemented a feature. Nice.
It's very different to control the flow of an app in a config file compared to in code. Just a light bulb moment that I wanted to share.
Listening to: Puddle Of Mudd - Nobody Told Me
Can you elaborate on the details?
ReplyDeleteWe had a java class that preformed an action. Let's say that it added an item to a shopping cart after you were previewing it. Now, there are a couple of ways to get to the preview depending on what type of item you are previewing (previewA and previewB).
ReplyDeleteOn successful "add to cart", you want to return to the same preview page. In the java file you just forward to "success" (a lookup in the config file).
We just had to define different actions for both previews and change what "success" mapped to since all the logic in the code is the same.
Struts is useful because it helps you reduce any lateral coupling. Each action could just have knowledge of the business component that it has to interact with.
Is that clear?
*sigh*
ReplyDeleteThis solution lasted far shorter than it should have. I ended up having to (more or less) put a message in to determine what was calling it. It was because the UI was *almost* the same, but it wasn't *exactly* the same. By putting in the pram. it allows us to not do a unnecessary db call.
That solution will last until I figure out a better way to do it.
Not really clear.
ReplyDeleteYou said: "Now, there are a couple of ways to get to the preview depending on what type of item you are previewing (previewA and previewB)."
What I'm guessing you mean is that there are different types of preview pages depending on the type of item you are previewing.
Then you said: "On successful 'add to cart', you want to return to the same preview page. In the java file you just forward to 'success' (a lookup in the config file)."
Which I'd guess means: On successful "add to cart", you want to return to the original preview page, which varies based on the item type. The the java source code, you forward to "success", which is defined in a configuration file to map to the correct preview page based on the item type.
Is that right?
BTW, I'm still not sure what that last comment means.
Sorry about that. Yes, you are correct in your interpretation of my post.
ReplyDeleteMy last comment was how I had to put in a hidden field to determine which preview to use. It is because on one of the previews we go to the db to pull out some info. We could just do it for both, but then we would be doing a needless db call.
I hope that it clearer now.
... and by hidden field you mean a hidden html input.
ReplyDelete