shared items

Sunday, October 21, 2012

MultiSelect in rails with Collection_select

Model1
    attr_accessible :model2s, :model2_ids
    has_many :model2s

Model2
   belongs_to :Model1



1. Have a model with attr_accessible :model2_ids

2. f.collection_select :model2_ids , Model2.all, :id, :name, {},{:multiple=>true,:size=>5}

The trick is "model2_ids"

Thats it !

Saturday, October 20, 2012

JQuery on Rails 3.0.11

Steps to replace Prototype with Jquery

1. open Gem File
2. include gem 'jquery-rails'
3. bundle install in your rails app directory
4. bundle show jquery-rails
5. rails generate jquery:install [--ui]

If you get invalid spec error while doing bundle install, you could do one of the following
1. Update ruby gems to the latest version
     a. gem update --system

or

1. Modify the erroneous gem spec reported
    a. Open the file , look for the reported data format error and remove all the time section
          example : 23-10-12 00:00.000000000z   to  23-10-12

That's it !


Friday, October 12, 2012

ROR: Multiple references to the same table in the parent table

class Address < ActiveRecord::Base
  has_many :customersend
 
class Customer < ActiveRecord::Base
  belongs_to :billing_address, :class_name => 'Address', :foreign_key => 'billing_address_id'
  belongs_to :shipping_address, :class_name => 'Address', :foreign_key => 'shipping_address_id'
end


Source : Linky

Thursday, October 4, 2012

Call Stored Proc from Java with sql types in Stored Proc Call

        final String typeName = "T_ALL_RECORD";
        final String typeTableName = "T_ALL_RECORDS";

        // Get a description of your type (Oracle specific)
        final StructDescriptor structDescriptor = StructDescriptor.createDescriptor(typeName.toUpperCase(), connection);        
        final ResultSetMetaData metaData = structDescriptor.getMetaData();

        // Call the procedure (or whatever else) that returns the table of a custom type
        CallableStatement cs = connection.prepareCall("{call ult_pkg.get_data_Q1(?, ?)}");
        cs.setString(1, "the_id");
        // Result is an java.sql.Array...
        cs.registerOutParameter(2, Types.ARRAY, typeTableName);     
        cs.execute();


http://stackoverflow.com/questions/11621638/how-to-call-procedure-with-out-parameter-as-table-type-from-a-java-class

Friday, May 11, 2012

Create EXE for java apps



Launch4j Executable Wrapper

http://sourceforge.net/projects/launch4j/#screenshots
Launch4j is a cross-platform tool for wrapping Java applications distributed as jars in lightweight Windows native executables. The executable can be configured to search for a certain JRE version or use a bundled one, and it's possible to set runtime options, like the initial/max heap size. The wrapper also provides better user experience through an application icon, a native pre-JRE splash screen, a custom process name, and a Java download page in case the appropriate JRE cannot be found.

Wednesday, May 9, 2012

Tortoise SVN asks for password repeatedly!

Tortoise SVN
right click on desktop -> Tortoise SVN-> settings -> saved data -> authentication data (button press 'clear') !
try logging in now again !

Monday, October 10, 2011

Text Overlapping over image ( JSF/Facelets )

CSS:
#_1234bg


{

display:block;

position:absolute;

z-index:0;



}

.c1{width:290px;}

.c2{width:140px;}

.c3{width:100px;}

.c1a{width:130px;padding-left:160px;font-size:10px;font-weight:bold;}

.c2a{width:50px;padding-left:91px;font-size:10px;font-weight:bolder;padding-top: 10px}

.c3a{padding-left:40px;}
 
 
JSF CODE :
<  t:div style="width:800px;height:700px;">
<  t:div id="_1234bg">
<  h:graphicImage id="image1" alt="aa" width="701" value="#{facesContext.externalContext.requestContextPath}/css/wm.png" />



<  h:panelGrid style="position:absolute;font-size:large;margin-left:15px;margin-top:25px;" columns="3" columnClasses="c1, c2, c3 c3a">

<  h:outputText value=" "/>

<  h:outputText value="#{homeManagedBean.account.cy.box1}"/>

<  h:outputText value="#{homeManagedBean.curryr}"/>



<  t:div>





This is specially useful when the user wants to print text overlaid on a background image.

Wednesday, September 21, 2011

Run Jobs on Mainframe from Java using FTP



ftp my.zos.mainframe

userid

password

quote site filetype=jes

put job.txt

quit



http://www.ibm.com/developerworks/systems/library/es-batch-zos.html

Thursday, September 16, 2010

vonage router behind another router

http://portforward.com/english/routers/port_forwarding/Dlink/DIR-615/Vonage.htm

Friday, May 21, 2010

Hibernate: Fixed char(n) in mysql to java string

Please see this link. I had same problem:




http://forum.hibernate.org/viewtopic.ph ... highlight=



Please see last entry which solved my problem. In mapping file if you can make changes link this:



from your ref:











change to:









This should solve you problem. By default Hibernate assumes that the column is string and compares against VARCHAR(255). This problem happens only when schema is validated. For any other cases this problem will not arise

Source: https://forum.hibernate.org/viewtopic.php?f=1&t=956019&start=0

Tuesday, April 27, 2010

Accessing Spring beans from Quartz jobs

http://cse-mjmcl.cse.bris.ac.uk/blog/2007/06/20/1182370280435.htm
The Spring Framework integrates with the Quartz scheduler in a way that makes Quartz much easier to use. Although in order to use Spring beans with your Quartz jobs you have to deviate slightly from the usual Spring "dependency injection" way of doing things. According to the Spring API this is necessary because Quartz itself is responsible for the lifecycle of its Jobs.



I was recently refactoring my use of Quartz and Spring in my feed aggregator web application. Rather than explain the internal workings of my application at this time, I will explain some features I discovered with reference to James Goodwill's recent simple example of using Quartz and Spring together. James shows how a "cron style" job can easily be created by configuring Quartz Job, trigger, SchedulerFactoryBean and loading up the application context.

Source : http://cse-mjmcl.cse.bris.ac.uk/blog/2007/06/20/1182370280435.html

Monday, March 29, 2010

javafx charts

http://java.sun.com/developer/technicalArticles/javafx/v1_2_charts/

VM setting in Eclipse

http://wiki.eclipse.org/Eclipse.iniSpecifying the JVM


One of the most recommended options to use is to specify a specific JVM for Eclipse to run on. Doing this ensures that you are absolutely certain which JVM Eclipse will run in and insulates you from system changes that can alter the "default" JVM for your system. Many a user has been tripped up because they thought they knew what JVM would be used by default, but they thought wrong. eclipse.ini lets you be CERTAIN.



The following examples of eclipse.ini demonstrate correct usage of the -vm option.



Note the format of the -vm option - it is important to be exact:



The -vm option and its value (the path) must be on separate lines.

The value must be the full absolute path to the Java executable, not just to the Java home directory.

The -vm option must occur before the -vmargs option, since everything after -vmargs is passed directly to the JVM.

Windows Example

-showsplash

org.eclipse.platform

--launcher.XXMaxPermSize

256m

-vm

C:\Java\JDK\1.5\bin\javaw.exe

-vmargs

-Xms40m

-Xmx512m

Source : http://wiki.eclipse.org/Eclipse.ini

SQLite jdbc

http://stackoverflow.com/questions/41233/java-and-sqlite

http://www.zentus.com/sqlitejdbc/

Sunday, January 17, 2010

javascript : Select all checkbox

function checkall()
{
   var len =document.getElementsByName('asid');
   if(len.length != null)
   {
     for (var i = 0; i < len.length ; i++) {
   len[i].checked = true;
   }
   }
   else
   {
        len.checked = true;
   }
}

function clearall()
{
var len =document.getElementsByName('asid');
   if(len.length != null)
   {
     for (var i = 0; i < len.length ; i++) {
   len[i].checked = false;
   }
   }
}

Monday, December 28, 2009

warbler

http://blog.headius.com/2008/08/zero-to-production-in-15-minutes.html

Thursday, November 12, 2009

Removing Stale Rails Sessions

Source : http://www.realityforge.org/articles/2006/03/01/removing-stale-rails-sessions