Research Log of Web Science Students

Computer Science is not simply programming

Search

leave a comment »

My Christmas break ended yesterday and today I picked up where I left off last Friday: finishing up the search modules function of Hardwire. I knew I finished this last month but that version was very basic. It only made the user add and remove modules.

I wanted to include pagination in this version to come up with a more realistic output. I had new ideas to improve the code from before and so I wanted to try them out as well. My search a module function is located in the ModuleController as well as the bookmark a module and the “un-bookmark” a module codes. The first one is correct and it should be there but the last two codes should be pulled and placed in a new LearnerController because the subject here is the learner not the module.

Going to the search page

Searching…

The search results. Add and remove buttons are placed according to whether the current user has bookmarked that module or not.

Just like I mentioned earlier I found a slick way to do it in the Controller:

mav.addObject("modules", search_results);
mav.addObject("favModules", favModules);
<c:forEach var="module" items="${modules}">
  ${module.title}<br/>
  ${module.objective}<br/><br/>		
   <c:choose>
    <c:when test="${fn:contains(favModules,module.id)}">
	Remove
    </c:when>
   <c:otherwise>
    <form action="/addModule" method="POST">
      <input type="hidden" value="/searchmodules" name="callback">
      <input type="hidden"  name="page" value="${page}"/>
      <input type="hidden" name="tag" value="${tag}"/>
      <input type="hidden" name="id" value="${module.id}"/>
      <input type="submit" value="add"/>
    </form>			
   </c:otherwise>
</c:choose>
<br/><br/>
</c:forEach>

The way I did it in the social networking part of the app is that I wrapped my query results in custom class with custom attributes and populated them! In hindsight it was a really crazy thing to do. But then experience has taught me better and I am really proud of it.

All in all, this took me more than 4 hours to make! But I still have a lot left to do like the add and remove button functionalities. Whew. Guess it’s back to work for me.

Advertisements

Written by Jose Asuncion

December 20, 2009 at 1:52 pm

Posted in Hardwire

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: