Friday, April 30, 2010

xFruits - Compose your information system

 

image

xFruits is a Web 2.0 service. You do not need any specific learning to deal with it.
It is a free online service offering to every user the possibility of:
- Enriching your home
- Enlarging your blog's functionalities
- Creating, generally, your information system from the RSS feed
XFruits makes possible the Mashup RSS creation in a very simple way thanks to the Composer.
You can assemble the bricks together so as to build your own feed-based service.
"xFruiter" service's users are referenced.
xFruits has been thought of as from its origin to be upgradeable and modular, and thus, to allow a developer's community to take part in the project. Our ambition is to create dozens of new bricks!
XFruits is already available in English, French and Spanish version, a Japanese version will be available soon.
This service is still in Beta, we count on the xFruiters's ideas and suggestions to help the service to advance.
One of the Home's component is intended for collecting your ideas. The most successful ideas will be integrated into xFruits.
XFruits is a service sponsored by the WM company, based in Ajaccio, which is specialized in the CMS on request.

I found that Yahoo pipes does not recognize or update RSS. Trying xFruits for now…

Thursday, April 29, 2010

Facebook Group RSS Feed

 

image

This is a great way to get RSS updates from facebook groups

Tuesday, April 27, 2010

Dojo Ajax with Grails

Grails can be very frustrating and deceptive. It is still evolving and there is a long way to go. Here is another issue which wasted my time.

I was trying out ajax with dojo. The example says:-

to install plugin:- grails install-plugin dojo

Header of gsp:

 <g:javascript library="dojo" />


Ajax link :



<g:remoteLink action="delete" id="1" >Delete Book</g:remoteLink>


One thing to remember here is id is the parameter you want to pass. You cannot change it to say order=”ABCD”. I have to pass it as id and retrieve it in the action as params.id. Gosh! I wonder if some wise guy can rename id to params

Monday, April 26, 2010

Add blog to Technorati

Technorati is an Internet search engine for searching blogs, competing with Google and Yahoo. Everyday, thousands of visitor search for information through it.
If your blog is registered in technorati, a bigger chance it will be seen by visitors.
This can increase your SEO Blog rank.
To register in Technorati, follow below simple steps:
1. Sign In on Technorati, if not register, please Join on Technorati
2. Click your account (your userID), it's near signout link.
3. Click Claimed Blogs tab.
4. Click Claim a new blog link below.
5. Enter your Blog URL then click Begin Claim Button.
6. Technorati sends you a claim code through email  :-

This is an automatically-generated email.
Thank you for submitting your blog claim on Technorati. Technorati will need to verify that you are an author of the site http://ejvyas.blogspot.com by looking for a unique code. We have just assigned the claim token 6H7UQ7UK7B76 to this claim. Please visit http://technorati.com/account/ for more details, including how to use the claim token.
Thank you.

7. You also get another email if you do not use your code :-

This is an automatically-generated email.

Thank you for submitting your blog claim on Technorati. Unfortunately, we have encountered a problem reading your site's data.  Please log into technorati.com and go to http://technorati.com/account/ to update any necessary site information and continue the claim process.
Thank you.

8. My profile shows the following message:-

image

9. That is when I realized that I have to add a blog post to activate this

Now, your blog is registered in technorati.

Sunday, April 25, 2010

Beware when using statics in Java Web Services

static members can be very dangerous when used in Java Web Services. Since you get just one instance unknowingly you might share a common object or variable or worse introduce cross-talk between two or more callers

Saturday, April 24, 2010

Combining Spring with Struts in a single war file

web.xml for combining Spring with Struts

.do request go to Struts ActionServlet

.sp request go to Spring DispatcherServlet


    <display-name>Display Name of the Project</display-name>
    <description>Description of Project</description>
    <servlet>
        <servlet-name>action</servlet-name>
        <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>2</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>*.sp</url-pattern>
    </servlet-mapping>

Friday, April 23, 2010

New ODBC data sources via mdb file

 

1. Go to Control Panel-> Administrative Tools –> Data Sources (ODBC)

Control Panel_283e2

2. Select the mdb file that contains your data using the Select button and browsing to the file. Give it a name and press OK. If you use this ODBC source in your program you should be careful in specifying the same name.

image

3. You should be able to find see the data source in the User DSN Admin screen

image

Tuesday, April 20, 2010

Java Development Toolkit issues with Firefox

image

image

The "Java Deployment Toolkit" that is highlighted in the list of plugins is part of Java and is an insecure version. It's been blocklisted. See: https://www.mozilla.com/blocklist/

Java Deployment Toolkit, versions 6.0.200.0 and older. Reason: security vulnerabilities (see bug 558584).


According to Secunia Advisory SA39260 you should update to Java 6 Update 20 to resolve the issue. Note that, according to US-Cert Vulnerability Note VU#886582 updating to Java 6 Update 20 may still leave you vulnerable to the exploit in some cases. After updating Java you should search for and remove any remaining copies of "npdeploytk.dll" (or rename to "Xnpdeploytk.dll", which is what I did). See this forum topic for more information:
http://forum.avira.com/wbb/index.php?page=Thread&threadID=111317
Your list of plugins shows an outdated Java 5 Update 22 plugin. You should make sure to uninstall older Java versions and remove any outdated Java files in your Program Files\Mozilla Firefox\plugins folder. See http://kb.mozillazine.org/Java#On_Windows if you need help updating or uninstalling Java. For help with other plugins, read http://kb.mozillazine.org/Issues_related_to_plugins and go through the related articles here http://kb.mozillazine.org/Category:Plugins

In other words, after updating to Java 6 Update 20, the C:\Program Files\Mozilla Firefox\plugins folder should have included an updated and enabled Java Deployment Toolkit plugin named npdeployJava1.dll and the old npdeploytk.dll file should have been gone from that location (it was for me). If an old npdeploytk.dll plugin remained there (or in the "C:\Program Files\Java\jre6\bin\new_plugin\" folder) then it would still show up in the Tools -> Add-ons -> Plugins list as "Java Deployment Toolkit" with the old version number but it should be disabled by the blocklist. If the OLD version is still enabled it should be manually disabled. If you want to get the OLD version of the Java Deployment Toolkit out of the Plugins list you can delete all copies of the file npdeploytk.dll from your system (or rename to Xnpdeploytk.dll ).

Sunday, April 18, 2010

Calling Non-spring code from Spring

Given below is an example of how to manage connections when calling non-Spring code. Remember to close connection retrieved since Spring will not manage it. You may use extends SimpleJdbsDaoSupport for the class as well and then use the connection retrieved from existing pool. But jdbcTemplate.getDataSource().getConnection() and dataSource.getConnection() are create a brand new connection.

@Service
public class BomImpl {

@Autowired
private DataSource dataSource;

@Transactional(readOnly = true, propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void functionName(Recipe recipe) throws Exception {

Connection conn = null;
try {
//conn = jdbcTemplate.getDataSource().getConnection();
//this will return a brand new connection instead of existing one.
conn = DataSourceUtils.getConnection(this.dataSource); //this is the right way to grab the current connection
refDesResult = instance.getRefDesList(conn,
recipe.getOrder().getBusinessUnit(), item, recipe
      .getOrder().getNewStartDate(), "PR", "PR", 99);
} finally {
      if (conn != null) {
            DataSourceUtils.releaseConnection(conn, this.dataSource);
}
}//finally

}//functionName


}//class

Thursday, April 15, 2010

Upgrade issues with Eclipse and Aptana

I had Eclipse and Apatana installed for asha-web-dev. Last week when I was trying to link JIRA Issue connector to Eclipse I had to update Eclipse 3.5.2 to 3.5.3 which broke my Aptana. My Aptana RadRails perspective does not show up now :(

I will keep you updated when I fix my dev environment

 

Problems occurred restoring perspective.
  Could not find view: org.rubypeople.rdt.ui.RubyExplorer
  Could not find view: org.rubypeople.rdt.testunit.views.TestUnitView
  Could not find view: com.aptana.ide.server.ui.serversView
  Could not find view: org.radrails.rails.ui.ViewGenerators
  Could not find view: com.aptana.rdt.ViewRakeTasks
  Could not find view: com.aptana.gems.ui.ViewGems
  Could not find view: org.tigris.jira.ui.issueTracker

Wednesday, April 07, 2010

g:select chooselist problems

class ProcessParamNames has the following fields:-
String id
String paramDesc
String displayName
ProcessParamType type





1. Note the single quotes for the argument of findAll so that the from double-quotes do not break
2. Note the use of findAll instead of findAllByType or findWhere since it belongsTo another table

1. Cannot use ProcessParamNames.findAllByType('PID') since there is no such method accepting String as input
2. Cannot use ProcessParamNames.findAllWhere(type:'PID') for the same reason

Copy functionality in Grails application

Following is easy code you can implement a Grails application to implement copy functionality:-

list.gsp

The primary key is passed as a parameter to the create action which effectively creates a blank template and fills up with existing record

<td><g:link action="create" params="${processParamAssignInstance.getPK()}">Copy</g:link></td>


Domain class



Here defPK contains all the variables which make up the composite key of the domain class



def getPK(){
["workCenterCode":workCenterCode,"mfgAreaLoc":mfgAreaLoc,"oper":oper,"processParamTemplate":processParamTemplate,"fab":fab,"matchValue":matchValue,"paramName":paramName]
}

Grails

Grails is a "full stack" framework. Which means that it will help you with the whole application, including persistence.
The easiest way to handle your relational data in a Grails application is to let Grails do it for you. Grails will use Hibernate to create your database artifacts based on your domain classes. To take advantage of this you just need to follow a simple convention.
If you have an existing database that you need to access from a Grails application you have to do a bit more work, but it's still not that difficult (usually). My preferred mechanism for mapping to an existing DB is to use Grails' mapping DSL. http://grails.org/GORM+-+Mapping+DSL. You can also use JPA annotations in your domain classes or you can create Hibernate mapping files and place them in your application's conf/hibernate directory. You can read more about these approaches here: http://grails.org/Hibernate+Integration
Weak points:
The first one is a practical limit of one data source for domain classes. There is a plugin that helps with this somewhat, but there are still limitations. I don't know if anyone is working to improve this other than the developer of the plugin in question.
Next, is the testing. This has improved significantly and I don't have any complaints about it but I've heard that Rails has better testing support baked into it, I know that there are several plugin developers working to improve the Grails testing story and they are coming up with some cool stuff.
Third, is the large stack traces that you get with errors in Grails. They do get huge, but this doesn't really bother me (at least once I increased my console buffer size). This has also gotten better with some stack trace sanitization in recent versions of Grails, but I still hear people complain about it.
1. Memory :- I do not believe this was expected. Double the size of war file <not a big issue> and amazing amount of heap space and objects it holds. Brought down my production tomcat (shared with other Spring web applications). I have generous amount of memory, processing power and heap size (tuned)
2. Legacy database support *** :- I do not want to use standard id based tables or simple String. I had to do a lot of coding to take care of Complex composite keys with foreign key relationships. Also I do not like the way you have to query other tables (not in the domain)
3. Plugins :- Need to be more mature. Some basic plugins like searchable, filter pane, export work for basic feature. Well - I don't think any user uses these basic features and then you need excessive customization to get these to work for tech savvy user. For e.g. Ms Access can perform better searches and filters. I have identified some bugs (may be fixed in the newest release)
4. Documentation and more examples :- I know the basics but some plugins and strategies don't always work as given in the documentation. Need more complex examples and tutorials.

So this is arguable not a weak point. Most Grails users would consider this a strong point and feature of grails, but I find it to be somewhat of an anti-pattern. I don't like the fact that in a grails GSP I can write groovy code. So for example...
  1. <g:each in="${Book.list()}"> 
  2.      <p>Title: ${it.title}</p> 
  3.      <p>Author: ${it.author}</p> 
  4. </g:each> 
<g:each in="${Book.list()}"> <p>Title: ${it.title}</p> <p>Author: ${it.author}</p> </g:each>
Note Book.list(). This goes against everything I learned while growing up with JSP and the EL. You now have the ability to call arbitrary methods on objects directly in the view. And I think this is a horrible thing to do. I suppose this could have also gone in the Grails best practices thread in that I'd say a best practice is to avoid scripts in GSP like the plague.

A) promoted with doing this as demos and examples and/or B) didn't allow the alternative poor design choice.

Monday, April 05, 2010

Java 1.6 update 19


Its amazing how fast Java is updating their minor versions and leaving some very angry customers behind. Version 1.6.15 broke the Java WebStart feature of updating the clients when releasing a new version. Java WebStart technology allows user to start application software for Java Platform from the Internet using web browser.

Unlike Java applets, Web Start applications do not run inside the browser, and the sandbox in which they run need not have as many restrictions, although this can be configured. Web Start has an advantage over applets in that it overcomes many compatibility problems with browsers' Java plugins and different JVM versions. On the other hand, Web Start programs cannot communicate with the browser as easily as applets. To assist migration, users can also invoke a Java Applet as a Java Web Start application.

Java 1.6 update 19 which released a few minutes back has an interesting security warning dialog box that appears while running a Java based applet or application:-

Picture (Device Independent Bitmap)
Picture (Device Independent Bitmap)
Picture (Device Independent Bitmap)


 This is due to the Java version upgrade to minor version 19. They have added this new "feature" : http://www.java.com/en/download/help/error_mixedcode.xml

You will have to decide which is the best setting for you. I would suggest we select point 2 as a workaround for now.

Saturday, April 03, 2010

Query data not in domain classes

This is how you would query from outside tables not contained in the domain classes.

Declare dataSource variable in the controller and Grails will inject the data source

class MyController {
    def dataSource

   
   
Use the dataSource variable to query as below:-

    def myMethod(int a){
        groovy.sql.Sql sql = new groovy.sql.Sql(dataSource)

        String query= "select count(*) as count from table_name where column_name ="+a;
        def result = sql.firstRow(query);

        if(result?.count>0){
            return true
        }else{
            myInstance.errors.rejectValue("domainVariable", "Combination does not exist")
        }
    }

   
There are other ways to query like below:-
        def result = []
        sql.eachRow("select distinct(column_name) from table_name where column2_name=?",[params.param2_name],{ row ->
                result << row.column_name
            });

           
Make sure you check out the groovy.sql.Sql javadoc for more options to query.

Thursday, April 01, 2010

Grails - g:select, remoteFunction and multiple params

Here is an example of using two params in a remoteFunction call or any similar remote call in Grails, which can be extended to use more than two if needed by separating subsequent params with &

            render g.select(from:workCenters, name:"workCenterCode", value:selectedValue.get(0).toString(), onChange:"${remoteFunction(controller:'processParamOverrides',action:'mfgAreaList',update:'mfgAreaLocDiv',  params:'\'workCenterCode=\'+document.getElementById(\'workCenterCode\').value+\'&endWcOpSeq=\'+document.getElementById(\'endWcOpSeq\').value+\'&orderNum=\'+document.getElementById(\'orderNum\').value' )};")