This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Cloud Application Architecture Patterns: Designing, Building, and Modernizing for the Cloud and have Kyle Brown, Bobby Woolf and Joseph Yodor on-line!
See this thread for details.

Kev Adams

Greenhorn
+ Follow
since Oct 27, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Kev Adams

Hi guys,

Is there any area of the certification test that I should focus on more than the others, or are they all pretty much equally represented?

Thanks,

Kevin
I have extended select.ftl to include the "title" attribute in the <option> tag that the <s:select> generates.

Now, I want to dynamically insert a rendered <select> tag into my page using the new template. For instance, I have a radio button that lets you choose which list to insert into the page.

In struts.xml, I have the following:



My question is, how do I populate the data in the <select> tag? Normally, that's done by the parameters to <s:select> (i.e. list=, listKey=, etc...)

Or, to put it another way, how does my action class need to look to make sure the tag renders properly?

If I'm going about this the wrong way, please feel free to instruct me otherwise.

13 years ago
I came across some code today that looks like this:



Would it not be better, not only for readability, but for memory usage to do it like this:



My thinking is that Java has to create a temporary memory space to hold whatever is returned by getObjA().getObjB().getObjC() each time.

Is that correct?
13 years ago
If I want to include code in my JEE application to display "Production", "Test", or "QA" depending on the server it's installed on, what is the best way to do that?

Can I use JNDI to look up a value on the server? If so, where would that go?

Any help would be appreciated.

Rupesh Mhatre wrote:Yes in case of model driven only getModel method gets exposed.



I mentioned in the original message that I was using ModelDriven. I'm not having a problem with that aspect of it.

Is there anyone else who understands what I'm asking? If not, I can try to explain it a different way.

14 years ago

Manuel Schenkhuizen wrote:being built? AJAX?



Not with AJAX. Because I am using a collection-backed radio button, the Collection which backs it is provides the data. So, the form is being "built" before it is displayed.

Rupesh Mhatre wrote:Thanks to ParameterInterceptor in struts 2 which puts the request parameters on ValueStack so that OGNL can pull data.



Yes, but the point of the original question is... Why does it NEED to call the getter method when you SUBMIT the form? It just needs to call the setter method (in my example, "setPriority").
14 years ago
Just checking in. Does anyone know the answer to this?
14 years ago
Why is it that when a form with a collection-backed radio button gets submitted that Struts 2 calls the getter for the list?

For instance:


The code above calls "getPriorityList()" when I submit the form. I really only need the getter called when the form is being built.


I'm using Struts 2, version 2.2.1.1 and my action is both ModelDriven and Preparable.


Thanks in advance.
14 years ago

Jimmy Clark wrote:Also, it is unclear why you have a "service" object and a "domain/model" object. What is the difference between them?



The domain/model object contains my business logic. The service object is a thin layer over the domain object, as referenced in PoEAA's Service Layer pattern.

Keep in mind that objects contain data AND behavior.



Yep. I was simplifying the example because my domain object has that. The service layer doesn't really have any business logic.

The Business Delegate pattern will show you a way to connect a Controller to the business object model.



Thanks a bunch. I'll check that out.
I've been struggling with a proper way to get my controller to talk to my service layer. It's not that I can't get the two to talk, it's that I want to make sure that there are no dependencies between the layers

Specifically, what happens when you want to call some sort of "create" method in your service layer?

I'm using Struts2 as my controller. Here's a simple example



Here's a simple service:


The question is, what goes in the controller's (action's) call to the service? (i.e. line 15 in the action)
If you build a domain object in the controller and pass it to the service, then what's the point? You'd have to import the domain object into the controller and you could just call the business methods directly from the domain object.
If you make the service's createXxxx method accept a bunch of primitives, then you could end up with a very big parameter list, which is bad too.

Thanks in advance
I'm having a little trouble with the "conditionalvisitor" validator in Struts2. The "conditionalvisitor" validator is supposed to redirect the validation to the model, based on a condition. In my case, it is performing both sets of validation. This is causing false validation errors in my form.

My form has two radio buttons like so:



The "enableSingle()" and "enableMultiple()" call javascript functions to enable the fields of the radio button that is currently selected and disable the fields of the button that is not selected.

I'm using the ModelDriven approach and I have a single CRUD action (a la the Struts 2 In Action book). Inside that action, I have a "save" method, and my action alias looks like "CrudAction-save-validation.xml"

Here is the snippet from my CrudAction-save-validation.xml.



Normally, I'd never use the "==" to compare two strings, but this is how it is described on the Struts2 site here

I'm running this on a Websphere 6.1 server.

Has anyone encountered this before, and if so, what did you do? Unfortunately, there's not a lot of information about the "conditionalvisitor" validator from Google searches.
14 years ago
Does anyone have any information on this, or, do I need to give some other information to help anyone out?

Any help would be appreciated.
15 years ago
Is it possible in Struts 2 to set up the visitor validator with a ModelDriven action to have a variable context parameter, like so:



I tried this code and I created a "public String getMyContext()" method in my action. However, the method never got called. I don't know if the the context has to be explictly defined or not, and I haven't been able to find anything about it after searching the web.

The goal is to to have some conditional validation at the model level. For instance, say you were creating a new employee. You might have a radio button on your page that let you choose whether you were entering an American street address or a Canadian street address, and you'd want to validate the addresses differently. In addition, you wouldn't want to make any of the American street address fields required because they'd all be blank when you hit the submit button.

Using this, I could return a context of "american" or "candian" and have a Employee-american-validation.xml file and a Employee-canadian-validation.xml file.

Any help would be appreciated.
15 years ago
David,

That's what I'm doing. In the action that processes the search form, I'm putting the criteria into the session, and I'm letting an interceptor inject that criteria back into the action when the user comes back to the search page after having done something else.

The problem I'm having is that the content of the search criteria object has not been populated by the 'params' interceptor yet, because params comes before 'modeldriven' in the paramsPrepareParams stack. So, when I put the search criteria object into the session, it contains the wrong information.

Does that make sense?
15 years ago
Hi everyone,

I have a Search action that implements ModelDriven. Once a user enters his search criteria, I want that information put into the Session so that after the user has performed other functions on other pages (add, change, delete, etc...) and the user comes back to the Search page, the search will be performed again with the last search parameters.

To do this, I created an interceptor that will inject the search criteria object into my search action.

The problem I'm having is, *when* do I put my search criteria object into the session? I'm using the paramsPrepareParamsStack and after the first "params" interceptor fires, the request parameters are not in my model object -- yet. They don't get put into the model object until the 'modelDriven' interceptor fires, at least, that's what I see when I debug my action.

Any ideas?
15 years ago