Monday, October 29, 2007

A trick

javascript: document.body.contentEditable = 'true'; document.designMode = 'on'; void 0

remember the code above.
Try to put them on firefox's address box, something weird is going to happen.


:0

Tuesday, October 23, 2007

Becareful of sakai-api

Sakai provides a functional api, which can be used to interact with other components of sakai, such as User-api.
One thing worth of noticing is that, when you try to use such an api, never bundle this jar file within your project (component); otherwise there will be a conflict between the api within your project and sakai's.

Thursday, October 18, 2007

You can use Spring Framework to inject the service or use the cover:

1. Using Spring to get the service for your class (e.g. YourAppClass) (recommended)
1.1). Add the UserDirectoryService bean to the bean for YourAppClass


<bean id="org.sakaiproject.yourapp.logic.YourAppClass"
class="org.sakaiproject.yourapp.logic.impl.YourAppClassImpl">
<property name="userDirectoryService"
ref="org.sakaiproject.user.api.UserDirectoryService" />
</bean>


1.2). Add a variable and setter to YourAppClass to use the service in like so:

private UserDirectoryService userDirectoryService;
public void setUserDirectoryService(UserDirectoryService userDirectoryService) {
this.userDirectoryService = userDirectoryService;
}


2. Using the cover to get the service
* Note: This is not the recommended method, you should be using Spring to inject the service
2.1). Setup a variable to hold the instance from the cover

private UserDirectoryService userDirectoryService;


2.2). Get access to the service using the cover

userDirectoryService = org.sakaiproject.user.cover.UserDirectoryService.getInstance();






ATTENTION:: If you're using the first method, you should be sure of that your project is following sakai's structure, especially the bean's id.
I am using the second one.

Using Sakai API

In my case, the most useful object is the "user", because I need to identify who is the manager, and who is common member having merely the "access" ability:
Click here to know more.

first, get a "UserDirectoryService" via Spring Injection;
Then, use (UserDirectoryService) uds.getCurrentUser;
And now, we get a current user. With org.sakaiproject.user.api, we can know more about the operations on it.

Click here to know more SAKAI TIPS.

Wednesday, October 17, 2007

the "fmt" exception has been solved

It is amazingly easy.
What I need to do is to modify my "include.jsp" as:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>


<%@ include file="/WEB-INF/jsp/sakai.jsp" %>>
<body onload="<%= request.getAttribute("sakai.html.body.onload")%>;foobar()">




now, it should be working, no fmt exception at all.

Wednesday, October 3, 2007

Here comes Java file structure

  • org.sakaiproject.app-name
    • dao
      all dao api classes
      • impl
        all dao implementation classes
    • hbm
      hibernate mapping files only
    • logic
      all business logic api classes
      • impl
        all business logic implementation classes
    • model
      all value object POJOs
    • service (cannot use public)
      all publically accessible api classes related to the app
    • tool
      all java classes related to the tool (backing beans)
      • jsf, producers, params
        presentation specific classes related to the tool

Note: You may have your own package base instead of org.sakaiproject

File Structure

When develop a Sakai project, its structure is a thing worthy of concerning. Here it is:
  • app-name
    • api - project with all interfaces, model objects, and hibernate hbm files
      Deploy as a jar to shared [ no dependencies ]
      (optional) eclipse .project here (name the project -api)
      • src - includes interfaces, model objects, and hbm files
      • test - (optional) may include shared test data and mock objects which help other with tests
    • impl - project at this level
      Deploy as a jar, include in pack [api]
      (optional) eclipse .project here (name the project -impl)
      • src - includes java source for all implementations of apis
      • test - includes all unit and integration tests
    • pack - project for components stuff needed by Sakai (should just a set of spring config files)
      Deploy to components [impl (all in war bundle)]
    • tool - project for the tool (interface to the user)
      Deploy as a war [api]
      (optional) eclipse .project here (name the project -tool)
      • src - java src directory
        • java - any java code used for the tool only
        • webapp
          • app-name - JSF jsp files here
          • css
          • images
          • templates - RSF html templates
          • tools - Sakai tool.xml files goes in here
          • WEB-INF - lots of xml config files here (web.xml, applicationContext.xml, etc...
project.xml hints listed below each directory in italics, dependencies are in []