Research Log of Web Science Students

Computer Science is not simply programming

Posts Tagged ‘Spring MVC

Issue 4: Spring MVC + GWT + JSP

leave a comment »

From our wiki page,

ISSUE: Project Form Specification 6 and 7 – which loads first jsp or javascript?

Spec 6: module title will be in a hidden form field, retrieved by GWT, and displayed using GWT.

Spec 7: module learning activities will be comma separated in a hidden div or form field and displayed using GWT.

The solution to our Create a Project Feature requires the collaboration between the controller and the javascript (done with GWT). When a user wants to learn a course, he/she clicks that course and it sends the id to the controller. Controller gets the course from the database and generates a form that will allow the learner to add as many learning objects as he/she wants. The javascript displays all the learning activities of the course where the user adds learning objects.

But where does it get these from? The controller places the course details in a hidden input field. GWT retrieves this data, and layouts the form for us. Hence, our problem, will the jsp be able to print all the learning activities in the hidden input field before gwt tries to retrieve them?

I was afraid javascript would load first. Theoretically though I thought not. PHP is interpreted and returned with no more PHP tags, that’s why when we view-source a .php webpage, there’s only html in it and no more php. Why shouldn’t the same apply to jsp? Different design perhaps. I had to find out. I first went to my JSP and Servlets bible and looked for answers so I wouldn’t have to do an experiment. But because I was confident JSP is interpreted on the server like PHP is (and because I also wanted to code), I just did an experiment.

To cut the long story short, I never found out what happens on the server when you request for a jsp but I do one thing, jsp loads first before gwt can do it’s thing.

Advertisements

Written by Jose Asuncion

November 28, 2009 at 6:02 pm

Posted in Hardwire

Tagged with , , ,

Into the fray

with one comment

In football, you know when a substitute is thrown into the fray when it’s extra time and his is team a goal behind. Although I can’t say that we’re a goal behind, we’re definitely a little bit behind schedule this week. Don’t ask me why. So I decided to wait a little bit and take a dip into web services.

So I guess I was wrong. There is a way to machine read dynamically generated pages. I met Miko, a WSG graduate student, last night and he told me that it’s definitely possible. It’s more or less like this: a crawling web agent will execute a script that will query the web service with parameters and then machine read the results.

All this time I’ve been assuming that the xml that will be machine read will be embedded in the jsp. Although I have seen somewhere that it’s possible, it’s probably not what is required. What is required is an rdf document that will contain information.
Read the rest of this entry »

Written by Jose Asuncion

November 25, 2009 at 7:00 pm

Posted in Hardwire

Tagged with , , , ,

Binding our courses to a command class using Spring’s SimpleFormController

with 2 comments

I am currently trying to figure out how to bind our forms to the command object used by our SimpleFormController.

I have a form where I have two fields that I can add as much as I can. Think of it as like the upload file in gmail where I can add 1,2,3… files to upload only that I have two fields.

I am not so sure how this will check out using a SimpleFormController in Spring.

Here’s our form dilemna:

learning_activity

A user can add any number of learning activities to a course he makes. This makes our form “dynamic” or should I say “non-deterministic” in terms of the fields it has.

Read the rest of this entry »

Written by Jose Asuncion

September 15, 2009 at 3:46 pm

Posted in Hardwire

Tagged with ,

Using HashTables for models in Spring MVC

leave a comment »

Spring MVC controllers return a model and view:

return new ModelAndView([jsp],[modelName - to be accessed by the jsp], model you are returning);

As an example, heres the code to return a user’s nickname which the myPage.jsp will print:

String userNickname = "jeune";
return new ModelAndView("myPage","user",userNickname);

To print that in the myPage jsp using jstl tags simply code in:
<html>
.
.
.

<body>

.

.

.

${user}

.

.

</body>

</html>

But what if I wanted to print a whole lot of other things? This is inevitable if I want my web app to be dynamic.
Read the rest of this entry »

Written by Jose Asuncion

August 20, 2009 at 3:00 pm

Posted in Hardwire

Tagged with , ,