Tuesday, December 28, 2010

javascript : anchor href

use href="javascript:void(0)" in place of (#)
this is the most common method to get around this problem .
the anchor still get an href attribute , but it doesn't do anything .

Display tag : Editable Display Tag Table

http://demo.raibledesigns.com/appfuse/demos/users-edit.jsp

Wednesday, December 22, 2010

HTML : pop-up window

<script language="JavaScript">
function PopupMe1(){
myleft=(screen.width)?(screen.width-300)/2:100;mytop=(screen.height)?(screen.height-200)/2:100;
settings='top=' + mytop + ',left=' + myleft + ',width=300,height=200,location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no'
PopupWin1=window.open('sample.htm','PopupWin1', settings);
PopupWin1.focus();}
</script
<a href="javascript:PopupMe1()">Click here</a>

Tuesday, December 21, 2010

Spring and Hibernate : integration

<beans>
    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName">
            <value>oracle.jdbc.driver.OracleDriver</value>
        </property>
        <property name="url">
            <value>jdbc:oracle:thin:@server-lms:1521:orcl</value>
        </property>
        <property name="username">
            <value>cvupload</value>
        </property>
        <property name="password">
            <value>cvupload</value>
        </property>
    </bean>
    <bean id="mySessionFactory"
        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
        <property name="dataSource">
            <ref bean="myDataSource" />
        </property>
        <property name="mappingResources">
            <list>
                <value>cvDetails.hbm.xml</value>
                <value>TestType.hbm.xml</value>
                <value>Status.hbm.xml</value>
                <value>TestDetails.hbm.xml</value>
                <value>Tester.hbm.xml</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
                <!-- <prop key="hibernate.hbm2ddl.auto">create</prop> -->
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.max_fetch_depth">2</prop>
            </props>
            <!--<value>hibernate.dialect=org.hibernate.dialect.Oracle10gDialect</value> -->
        </property>
    </bean>

Sunday, December 19, 2010

The Steps Needed to Integrate and Configure Hibernate

1- Identify the POJOs that have a database representation
2- Identify which properties of those POJOs need to be persisted
3- Create Hibernate XML mapping files for each of the POJOs that map properties       to columns in a table.
4- Create the database schema using the schema export tool, use an existing                 database, or create your own database schema .
5- Add the Hibernate Java libraries to your application’s classpath .
6- Create a Hibernate XML configuration file that points to your database                 and   your XML mapping files.
7- In your Java application, create a Hibernate Configuration  object  that               references your XML configuration file.
8- Also in your Java application, build a Hibernate SessionFactory object from the
    Configuration object.
9- Finally, retrieve Hibernate Session objects from the SessionFactory, and write   your data access logic for your application.

Saturday, December 18, 2010

Dojo : Ajax

 <button id="bb" name="bb" value="AJAX" dojoType="dijit.form.Button" title="AJAX" onclick="koko();">
         <script type="text/javascript"  >
function koko(){
dojo.xhrGet( {
     
        url: "ajaxTest.jsp",
        handleAs: "text",

        timeout: 5000, // Time in milliseconds

        // The LOAD function will be called on a successful response.
        load: function(response, ioArgs) { //
          dojo.byId("dataArea").innerHTML = response; //
          return response; //
        }});
}
        </script>
    </button>
<textarea  id="dataArea" >
</textarea>

Wednesday, December 15, 2010

Dojo : DateTextBox

<html>
<head>
  <title>Dojo: Hello World!</title>

  <!-- SECTION 1 -->
  <style type="text/css">
      @import "js/dijit/themes/tundra/tundra.css";
      @import "js/dojo/resources/dojo.css"
  </style>
  <script type="text/javascript" src="js/dojo/dojo.js"
    djConfig="parseOnLoad: true"></script>
</head>

<body class="tundra">
  <script type="text/javascript">
     // Load Dojo's code relating to the Button widget
     dojo.require("dijit.form.Button");
  dojo.require("dijit.form.DateTextBox");
  </script>

  <button dojoType="dijit.form.Button" id="helloButton">
      Hello World!
      <script type="dojo/method" event="onClick">
         alert('You pressed the button');
      </script>
  </button>
<input id="q14b" type="text" name="date1" value="2005-12-30"
    dojoType="dijit.form.DateTextBox"
    lang="en-us"
    required="true"
    promptMessage="mm/dd/yyyy"
    invalidMessage="Invalid date. Use mm/dd/yyyy format." />
</body>
</html>

Sunday, December 12, 2010

display tag : http://displaytag.sourceforge.net/1.2/tut_basic.html

 

<display:table  name="cvList"  uid="cv" >
    <display:column style="width:30;" > <input type="radio"  name="selectRadio" value="${cv.id}"/>   </display:column>
    <display:column style="width:30;"> <a href="TestListBfr.do?id=${cv.id}">${cv.name}</a>  </display:column>
    <display:column style="width:30;" property="faculty" ></display:column>
    <display:column style="width:30;" property="department"></display:column>
    <display:column style="width:30;" property="email"></display:column>
    <display:column style="width:30;" property="mobileNo"></display:column>
   
    <display:column style="width:30" >
    <logic:iterate id="test" collection="${cv.tests}" >
    <font color="blue" style="font-family: serif; font-weight: bold;"> ${ test.testTypeBean.testType}  : </font>
    <br/>
     </logic:iterate>
     </display:column>
   
    <display:column style="width=30" ><a href="${cv.filePath}">
    <html:img src="images/download.jpg" style="height:20px; width:20px;border:0px" /></a>
     </display:column>
   
    <display:column style="width=30" >
    <a href="CVDelete.do?id=${cv.id}>">
    <html:img src="images/delete.jpg" style="height:20px; width:20px ;border:0px" /></a>
    </display:column>
   
    </display:table>

Saturday, December 11, 2010

integration : spring + struts + hibernate

part 1 : http://www.youtube.com/watch?v=ZzjtohbyO3g
part 2 : http://www.youtube.com/watch?v=kboAVCbUOIs&feature=related
part 3 : http://www.youtube.com/watch?v=RgxaK1b_Xw4&feature=related
part 4 : http://www.youtube.com/watch?v=2AnN4N0ccMI&feature=related
part 5 : http://www.youtube.com/watch?v=BupCsFLrJI8&feature=related
part 6 : http://www.youtube.com/watch?v=1fpKhcgouuo&feature=related
part 7 : http://www.youtube.com/watch?v=dA8N6zzjUkI&feature=related
part 8 : http://www.youtube.com/watch?v=rSNt_TcWwIU&feature=related
part 9 : http://www.youtube.com/watch?v=fbXR3Ay5pyw&feature=related
part 10 : http://www.youtube.com/watch?v=XELul06oHII&feature=related
part 11 : http://www.youtube.com/watch?v=9miAVKiDiIE&feature=related
part 12 : http://www.youtube.com/watch?v=kcetAbwbF6Y&feature=related

Monday, December 6, 2010

hibernate : mapping

The <id> element requires a <generator> element to be specified .
the generator's class  value is  [ guid | hilo |identity |increment |native |seqhilo |sequence |uuid ]  .

<one-to-one> Attributes :
* class => The property type of the attribute or field (if omit-
ted, this will be determined by reflection).
*constrained => Indicates that a foreign key constraint on the primary
key of this class references the table of the associated
class.
*foreign-key =>The name to assign to the foreign key enforcing the relationship.
*property-ref=>Specifies the column in the target entity’s table that
the foreign key references.

if you have an attribute of type Set, then you
will need to use a <bag> or <set> element to represent its relationship with the database.

the table attribute in the collection tags is representing The name of the table in which the associated entity is stored .

A bag(idbag) data structure permits unordered storage of unordered items, and permits duplicates .

<idbag name="idbag" table="nameidbag">
<collection-id column="id" type="int">
<generator class="native"/>
</collection-id>
<key column="fooid"/>
<element type="string" column="name" not-null="true"/>
</idbag>

Sunday, December 5, 2010

struts : client-side validation

When run on the client side, the validations will not allow the form to be submitted until they have all passed.


To enable client-side validation, you have to place the HTML Tag Library's javascript tag in each JSP for which you
want validation performed, as shown here:
<html:javascript formName="logonForm"/>



The javascript tag requires that you use the formName attribute to specify the name of a <form> definition from the
validation.xml file

struts : validation

Validator uses two XML configuration files to tell it which validation routines should be “installed” and how they should
be applied for a given application, respectively. The first configuration file, validator-rules.xml, declares the validation
routines that are plugged into the framework and assigns logical names to each of the validations. Additionally, the
validator-rules.xml file is used to define client-side JavaScript code for each validation routine.
The second configuration file, validation.xml, defines which validation routines are applied to which Form
Beans .

Enabling the Validator Plugin  ::
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
This definition causes Struts to load and initialize the Validator plugin for your application .



Notice that the validator tag encapsulates a javascript tag. The javascript tag is used to define client-side JavaScript
code for performing the same validation on the client side as is performed on the server side.

In order to use Validator, your application's Form Beans have to subclass one of Validator's ActionForm subclasses
instead of ActionForm itself.

You configure this Form Bean in the struts-config.xml file the same way you would a regular Form Bean.


The logical name given to the Form Bean with the form-bean tag's name attribute is the name that you will use when
defining validations in the validation.xml file.


Validator provides two additional ActionForm subclasses that allow you to tie validations to
actions instead of Form Beans. That way you can specify which validations to apply to the Form Bean based on which
action is using the Form Bean. For concrete Form Beans, you subclass org.apache.struts.validator.
ValidatorActionForm.  Inside your validation.xml file, you map a set of validations to an action path instead of a Form Bean name .

Saturday, December 4, 2010

lightbox : examples

http://leandrovieira.com/projects/jquery/lightbox/

http://warren.mesozen.com/jquery-lightbox/

 http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/

hibernate : properties

<property name="hibernate.hbm2ddl.auto">create</property>
 <property name="hibernate.hbm2ddl.auto">create-drop</property>
 <property name="hibernate.hbm2ddl.auto">update</property>
 <property name="hibernate.hbm2ddl.auto">validate</property>


<property name="show_sql">true</property>

Thursday, December 2, 2010

simple light box

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>LIGHTBOX EXAMPLE</title>
  <style>
  .black_overlay{
   display: none;
   position: absolute;
   top: 0%;
   left: 0%;
   width: 100%;
   height: 100%;
   background-color: black;
   z-index:1001;
   -moz-opacity: 0.8;
   opacity:.80;
   filter: alpha(opacity=80);
  }
  .white_content {
   display: none;
   position: absolute;
   top: 25%;
   left: 25%;
   width: 50%;
   height: 50%;
   padding: 16px;
   border: 16px solid orange;
   background-color: white;
   z-index:1002;
   overflow: auto;
  }
 </style>
 </head>
 <body>
  <p>This is the main content. To display a lightbox click <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a></p>
  <div id="light" class="white_content">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
  <div id="fade" class="black_overlay"></div>
 </body>
</html>

Wednesday, December 1, 2010

input text : readonly attribute

<script type="text/javascript">

function blah(bool) {
   if(bool) {
      document.getElementById("ta").readOnly = true;
   }
   else {
      document.getElementById("ta").readOnly = false;
   }
}

</script>

<textarea id="ta"></textarea>
<input type="checkbox" onclick="blah(this.checked)" />

Finally i got the job i dream

thanks www.harf.com   team