The specific case I am dealing with is really simple. Filling out the details of one business object requires either choosing one if its members from a pulldown box or deciding to create a new one. There is only 1 member that has this complexity for the original object. Let's use as an example a company which refers to a salesman. The page I am talking about is for building a new company. It could refer to an existing salesman (the pre-display load of the combobox) or require a new salesman (the top default value within the combobox (using existing implementation)). Once the user has made a decision in the combobox (and possibly filled out the company info) they hit an action button that I want to display all the information side-by-side (company and salesperson). Another button press would clearly be needed for confirmation. So, using the Front Man technique and good JSP practices how many pages are we talking about and where do the distinctions for separation occur?
So when you ask "how many pages", that isn't really a meaningful question.
I see a number of requests in your scenario. One that delivers the entire original HTML page, and some that deliver either HTML fragments (not whole pages), or even JSON data.
How all this ties into the Front Controller pattern is rather orthogonal. Regardless of what's going on on the client, the front controller is responsible for dispatching the request to the appropriate command. The fact that the command may respond with an HTML page, an HTML fragment, a JSON data construct, XML, or whatever else is rather irrelevant.
I'm not sure if that answered anything or not.
I see what you mean and I guess I would love to see a full page and partial page request ajax controller-using jsv(java server view? lol) implementation. An example. I will search around more but the examples I have found so far as so occluded with other concepts being the point that I cannot seem to sift a minimal set of what I need from them. If you know a good clean simple example and can link me to it I would surely appreciate it.
That's all there is to it. The response, an HTML fragment consisting of the list of option elements, is injected into the target drop-down by jQuery's load() method, so there isn't a whole lot of client-side script necessary.
Note that the server-side pattern is pretty much the same as just about any other task: front controller activates command, command collects request info, command delegates to model, command formats data for view, command forwards to view (for full-page responses, this is usually a redirect to the other page controller), view renders markup.
Here is the calling JSP code:
and here is the (used to be HTML fragment) JSP for content:
I've tried EL and other not so pretty solutions but I just do not know nor can I find a concrete example of how I refer to the load call's data element within the fragment.
The class members for the contact bean are currently all just simple Strings with default getters and setters.
The first code section I show is my original JSP file with the JQuery load call. The second code block is the entire JSP file that is loaded (in that calling case only) by the first code fragment. I would prefer that this second code file be JUST HTML but ... I figured that the data transfer/handling would be easier using a JSP (where I had more of an idea how to accomplish getting the data to display. I am very confused by the fact that my session scoped bean object is apparently not visible to the loaded file but my CSS class information carries straight through with no issues. I pass the JQuery ajax request (load) the contact bean class as its data object (this could be an erroneous use of the data object which seems to be oddly limited to name/value pairs but I am just guessing). I do not know the EL syntax (well enough) or other proper way to refer to the JQuery data object within my fragment file (be it finally JSP or HTML or whatever). I would love to see a concrete example of a controller class implementation if it doesn't use too many new concepts with which I am as yet unfamiliar. It's cool if learning a whole new concept is the best way and I just damn sure need to learn it. Simple Java and HTML are what I am hoping for. Did that clear up your questions?
Also I am scolding myself for not understanding how to implement the controller class properly as well. I am trying to learn it.
Chet Hawkins wrote:The first code section I show is my original JSP file with the JQuery load call.
Kinda odd to have a callback function on a load. You can use events to capture Ajax failures.
The second code block is the entire JSP file that is loaded (in that calling case only) by the first code fragment.
So the 2nd block is contactdisplay.jsp?
I would prefer that this second code file be JUST HTML
That would only be possible if the fragment is completely static, which doesn't seems to be the case.
I figured that the data transfer/handling would be easier using a JSP
I have no idea what you mean by that. If you mean being able to include dynamic data, then yes, you need a JSP for that.
I pass the JQuery ajax request (load) the contact bean class as its data object
Have you read this article? You seem to be a tad confused about what JSP is all about.
I do not know the EL syntax (well enough) or other proper way to refer to the JQuery data object within my fragment file
An Ajax request is an HTTP request like any other. Data is passed via request parameters.
All of this has nothing at all to do with FrontMan, by the way.
And please, in the future, use paragraphs!
Rather, the Ajax request should be going to the page controller (not directly to the JSP) which will fetch the contact info and pass it to the fragment JSP.
At most, the data passed from the parent page to the Ajax request should be the id of the contact to look up.
The second block is ONE EXAMPLE of code that would be loaded. There are 2 special values in the combobox, a blank representing no choice and a "New Contact" selection for the case of creating a new contact entirely. So, there are 3 cases of Ajax loads (or maybe just 2): I clear the content div if the blank is selected. I load it with edit boxes of the new contact choice is selected. For any other value in the combobox I display that contact's information in the content div.
I read the article you linked. I believe that I have a fair grasp on the concepts involved but I am lacking the concrete example to solidify the concepts in an implementation.
I suppose if the data object in the load call is limited to a map of name/value pairs that I must use it that way. I have a bean class that contains the list of contacts. I can pull the right contact from that list based on the combobox selection and map field labels to field values for the loaded view. I confess I do not know how to accomplish this on the client side in the JQuery change handler for the combobox. Can JQuery functions refer to my session-scoped beans and I suppose I should ask the question should it do so? If so then I need to know how.
I would love to use the Frontman technique and create a controller class but I cannot find a simple java/ajax example. All the examples I find use PHP, JSON, ASP, etc. Is there a simple java/JSP/HTML only example I can review of the Frontman technique so that I can understand how to implement it that way first before moving on to more complicated examples?
I suppose the contact bean is in the JSP because I am squishing controller functionality into that page which is a no-no. Assuming I could ever find an example of a controller class implementation that was simple java I could remove that need and pass only the selected contact key from the dropdown to the controller.
I did try referring to the contact bean within the fragment (just like I would have done in the calling JSP) and that did not work. So between your assertion that no passing around is necessary and that situation I am really confused.
And using the combination of jQuery and FrontMan makes this easy. Steps would be: