Adding css ResourceHandlers in Spring

Task

CSS to be added to the Spring 4 JSPs

Steps

  1. Create folder called resources\theme1\css under webapp. (I use maven project)
    Adding css ResourceHandlers in Spring.PNG
  2. Create main.css under css folder
  3. Add the resource handler in the Application context config
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = { "org.grassfield.gaja" })
public class ApplicationContextConfig extends WebMvcConfigurerAdapter {
    @Bean(name = "viewResolver")
    public InternalResourceViewResolver getViewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setPrefix("/WEB-INF/views/");
        viewResolver.setSuffix(".jsp");
        System.out.println("---> returning viewResolver");
        return viewResolver;
    }
    
    @Override
    public void addResourceHandlers(final ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/resources/**").
        addResourceLocations("/resources/theme1/").
        setCachePeriod(31556926);
        System.out.println("---> returning resourcehandlers");
    }
}

21BGMCUBE_1904636e

 

 

jquery – starter tutorial #4

If you haven’t checked the previous posts, please check the following
jquery – starter tutorial #3
jquery – starter tutorial #2
jquery – starter tutorial #1

We can more styles and animations. But I am too lazy to write all of those items here. But I feel I like to make a note of AJAX requests. One of the example below

<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $("button").click(function(){
    $("div").load('01.html');
  });
});
</script>
</head>
<body>

<div><h2>Let AJAX change this text</h2></div>
<button>Change Content</button>

</body>
</html>

 

AJAX and window.location.href

see there is a html line like this
<a href=”javascript:void(0);” onClick=”javascript:deleteGroup();”>Delete</a>
the delete group function is written as

function deleteGroup()
{
selectAll(null);
if (groupNames==”” || groupNames==”,”)
{
alert (“No Groups selected”);
return;
}
var a = confirm(“Are you sure you want to delete the selected groups? This change is permanent and this cannot be recovered!”);

if(a)
{
alert(groupNames);
window.location.href=”/final/admin/Egconfiggroupp.jsp?deleteGroups=”+groupNames+”&mode=delete”;
return;
}
}

It is working fine in Firefox but not in IE. Actually the control has been transferred to configgroupp.jsp and what it need to do, has been done. but it is not getting reflected in UI. it is static 😦 but when you add ” window.event.returnValue=false;” after window.location.href it is workign fine.

function deleteGroup()
{
selectAll(null);
if (groupNames==”” || groupNames==”,”)
{
alert (“No Groups selected”);
return;
}
var a = confirm(“Are you sure you want to delete the selected groups? This change is permanent and this cannot be recovered!”);

if(a)
{
alert(groupNames);
window.location.href=”/final/admin/Egconfiggroupp.jsp?deleteGroups=”+groupNames+”&mode=delete”;
window.event.returnValue=false ;
return;
}
}

What MS site says is, http://support.microsoft.com/kb/190244/en-us ,
The onclick event is overwritten by href tag etc etc….. oops. oh MS associates, why your browser keep on bugging me, while firefox is working fine?


—————————————————
*Free* software is a matter of liberty not price. You should think of “free” as in “free speech”.

Creating an application with GWT – Application creator

Today I have started with applicationCreator.cmd in the GWT folder!
Adding something important, GWT follows some structure in maintaining projects. As per specification, this is my assumption.
org/vaigai/shiksha – > this is the project root
org/vaigai/shiksha/client ->client side source files
org/vaigai/shiksha/server ->server side code
org/vaigai/shiksha/public ->web resources, public

oh no, dont get tired, the application creator script will do all these for us!

D:projectsgwtgwt-windows-1.0.21>applicationCreator.cmd org.vaigai.shiksha.client.myapp Created directory D:projectsgwtgwt-windows-1.0.21src Created directory D:projectsgwtgwt-windows-1.0.21srcorgvaigaishiksha Created directory D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshaclient Created directory D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshapublic Created file D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshamyapp.gwt.xml Created file D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshapublicmyapp.html Created file D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshaclientmyapp.java Created file D:projectsgwtgwt-windows-1.0.21myapp-shell.cmd Created file D:projectsgwtgwt-windows-1.0.21myapp-compile.cmd

Hey, amazing, a hello world is readily available with this newly launched project! see the client folder
Directory of D:projectsgwtgwt-windows-1.0.21srcorgvaigaishikshaclient 01/26/2007 01:50 AM 1,208 myapp.java 1 File(s) 1,208 bytes

also the hosted mode shell MyApplication-shell and the compiler MyApplication-compile is also issued with the newly created project.
issing the command myapp-shell will launch your program!! :)
coool..

then we can start editing the java, compile, view etc etc....!

so, hereafter lets see thost applications one by one!

for now, bookmark the link
http://code.google.com/webtoolkit

GWT – 1 : Re Entry into GWT

I got into GWT (Google Web ToolKit), and I found it is very useful to make future rich web applications. then somehow I cudnt continue it and left as such. Since I had very less time to roll in the web changes, I dint give much importance to gwt in our product. somewhat, I got good mood today, oops, at mid night… truely saying, I got some time, while downloading a divx 🙂

yes, here is the thing.
They offer a zip for windows (probably a tar for linux) which contains the SDK and some sample applications.

Actuallly why you need GWT?
no need for this question. but to complete this post, I need to tell this, right! Actually for those who cudnt write javascripts without bugs and for those who need better stable layout, google offers this pack. hey friends, you dont need to write js or html. just write equivalent java code, he will compile and give you the relavent html/css/js for you. 🙂 cool, isnt it!

I just extracted to one of the folders D:projectsgwtgwt-windows-1.0.21
See the following the content

D:projectsgwtgwt-windows-1.0.21>dir/w Volume in drive D is PERSONAL Volume Serial Number is BCE3-A541 Directory of D:projectsgwtgwt-windows-1.0.21 [.] [..] [samples] applicationCreator.cmd gwt-dev-windows.jar gwt-ll.dll gwt-user.jar junitCreator.cmd projectCreator.cmd swt-win32-3139.dll about.html about.txt index.html [doc]

See there is a applicationCreator.cmd . lets talk about this later. before that lets enter into the samples directory.

GWT had given five useful sample applications.
[DynaTable]
[Hello]
[JSON]
[KitchenSink]
[Mail]

let’s take one simple application now. ‘Hello’

As google says, there are two ways to run this application.

HOSTED MODE:
We will run _shell script here. it will just open the google browser and run your application.

WEBMODE:
Here we will run _compile script. it will compile your java file and create corresponding css, html, js files. you can view the html files later with your favorite browser. you have the java file. you can make some minor changes and see, how do you get the output!

see,
D:projectsgwtgwt-windows-1.0.21samplesHello>Hello-compile.cmd
Output will be written into D:projectsgwtgwt-windows-1.0.21samplesHellowww
com.google.gwt.sample.hello.Hello
Compilation succeeded

html files are written into D:projectsgwtgwt-windows-1.0.21samplesHellowww now

so, we came to an idea how it runs.

coming back to applicationCreator….
this will create a new project for you with necessary files.

D:projectsgwtgwt-windows-1.0.21samplesHello>applicationCreator.cmd net.vaigai.client.MyApp

package client is a must!

will get back to you with updates slightly later!

🙂

applet does not obey z-index

many are suffering with this problem. applets dont obey zindex. it causes ugly effects like the dhtml div layers goes behind the applets. what should be done. I have been searching but couldnt find a good solution. when we create all element dynamically using dom, It may be fixed. I am not sure. (FYI, milonic’s recent drop down is above the applet)

presently I am hiding the applet when I am invoking the layer. oops..

any solution?

—————————————————
*Free* software is a matter of liberty not price. You should think of “free” as in “free speech”.