Saturday, March 24, 2012

Install Printer on Ubuntu 11

Install Printer on Ubuntu 11

Download linux printer driver.

extract the driver file

it must contain *.ppd files those are printer driver

Go System setting - Printer - click Add button

Find network printer.

Type in IP

put driver location

done

Spingframework MVC set up servlet.xml

This is springframework MVC servlet.xml for WEB developers.

I hope it helps you, it is brief though.

It is tested in Spring 3.1 and 3.1.1 version.

context:component-scan : It will scan your java class package. which is coded in spring annotation based.

It has several ViewResolver as you see.

ContentNegotiatingViewResolver : It will show json result.if you want you can put xml,rss result view in ContentNegotiatingViewResolver.

InternalResourceViewResolver: It will show your jsp page.

SimpleUrlHandlerMapping : It will be handle if spring doesn't find any RequestMapping from Controller, the request will get to UrlFilenameViewController. it will resolve jsp file that is under /WEB-INF/jsp directory. so you don't have to make empty controller for each request mapping that doesn't have any logic.

I am sure it will trigger more curiosity if you are interested.

<context:component-scan base-package="yourpackage"/>

 <bean
  class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
  <property name="order" value="1" />
  <property name="mediaTypes">
   <map>
    <entry key="json" value="application/json" />
   </map>
  </property>

  <property name="defaultViews">
   <list>
    <!-- JSON View -->
    <bean
     class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
    </bean>
   </list>
  </property>
  <property name="ignoreAcceptHeader" value="true" />

 </bean>

 <!-- If no extension matched, use JSP view -->
 <bean id="viewResolver"
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="order" value="2" />
  <property name="viewClass"
   value="org.springframework.web.servlet.view.JstlView" />
  <property name="prefix" value="/WEB-INF/jsp/" />
  <property name="suffix" value=".jsp" />
 </bean>
 
 <bean name="myController" class="org.springframework.web.servlet.mvc.UrlFilenameViewController"/>
 
 <!-- If no view matched -->
 <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
     <property name="mappings">
         <value>
             /**/*.do=myController
         </value>
     </property>
  <property name="order" value="3" />    
 </bean> 

 <!-- Configure the multipart resolver for file upload request -->
 <bean id="multipartResolver"
  class="org.springframework.web.multipart.support.StandardServletMultipartResolver" />

 <!-- for rest url pattern support -->
 <mvc:default-servlet-handler />

 <mvc:annotation-driven />

Thursday, March 22, 2012

Jqgrid client side sorting

I have been searching how to sort Jqgrid in front end.

Someone was explaining it to make send a request to back-end,then sort it in database then return the result.
it doesn't make a sense to use grid framework then.

Finally, I have found it.
just add one more option "loadonce: true"

$(function(){ 
  $("#list").jqGrid({
    url:'Json Return URL',
    datatype: 'json',
    mtype: 'GET',
    colNames:['Model', 'Banner', 'Highlights'],
    colModel :[ 
      {name:'model', index:'model', width:120, key:true}, 
      {name:'banner', index:'banner', sorttype: 'number', align:'right', width:100}, 
      {name:'highLight', index:'highLight', sorttype: 'number', align:'right', width:100}],
    rowNum:20,
    height: 300,
    sortorder: 'desc',
    loadonce: true,
    viewrecords: true,
    gridview: true,
    jsonReader : {
  repeatitems: false,
  userdata: "userdata"
 }    
  }); 
}); 

that's it :)

FYI, when you set an attribute on colModel "sorttype: 'number'", it will sort as number.
if you don't, 2 will be top place when you sort it, even there is 11 or 10 so on..

Monday, March 19, 2012

How to play DVD that is locked for copy on Ubuntu 11.

How to play DVD that has copy protection on Ubuntu 11.

I just got a present, that is original DVD, but, it doesn't run on my Ubuntu.

※ Higher than Ubuntu 9.10, you need to do follow instruction

1. install medibuntu
sudo wget http://www.medibuntu.org/sources.list.d/karmic.list –output document=/etc/apt/sources.list.d/medibuntu.list
2. Add key medibuntu-keyring
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
3. install "libdvdcss2" pakage
sudo apt-get install libdvdcss2
4. enjoy dvd


I don't know what that it is detail. nevertheless it runs well now.
for more detail please check medibuntu click here

install nabi on Ubuntu

sudo apt-get install nabi
im-switch -c

reboot or log out and login

Wednesday, March 14, 2012

Install JDK 6 on Ubuntu 11

Install JDK 6 on Ubuntu 11

sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin

Saturday, March 3, 2012

Mybatis mapper xml file location in Maven project.

mybatis, Spring, Maven, Glassfish are well harmonized.
Development on my local computer was cruising well.

It's almost ready to finish project.

before launching it on production server.
we just fished to set up development server.
As it should be, I deployed it on to development server.

"mvn package" and get the war file.
deploy the war file to glassfish.

Errors occurred, Mybatis Mapper is missing?
"Mapped Statements collection does not contain value for ..."
What? why? I see all mapper xml/ class file. All files are placed right.
and working well on my local PC.

No clue.. for a while and while.
As new at maven, I had no idea that could happen.

Maven won't package except class files.
I knew that, so I located properties, conf files in resource directories.
but, I forgot that xml will be exculded as well.
xml mapper files are located under same mybatis mapper interface directories.
I have opened up the war file, As my guess, there was no mapper xml files on classpath directories.


Development local src directory file. there are mapper xml files are located.



But, Under maven target directory. xml mapper files are missing.



Solution, just re-located xml mapper files under resource directory in same directory hierarchy.
so, I will be packaged under same directory or you can change mapper location and put it.
as you know, you need to reconfigure the mapper location on spring then.

curiosity of Jquery "$(document).ready()" or "$()" what's different?

Just wondered. what's the difference and what it is.

I found out that is same either anyway.

$(document).ready(function() {
  // Handler for .ready() called.
});

Which is equivalent to calling:

$(function() {
 // Handler for .ready() called.
});

so, I will use shorter one.

Applied to the Hello Jquery!.

$(function() {
    $("a").click(function() {
    alert("Hello Jquery!");
    });
});

refer from : http://api.jquery.com/ready/