Posts Tagged ‘HTML element’

Web sites have changed since the appearance of HTML5 and CSS3 and also after the latest jQuery releases. They now have interesting features which make them more dynamic and also easy to load and navigate because most of the graphics that were previously jpeg, gif or png files are now mostly done in code. Most of the sites in this article are making use of these new technologies and that can be seen easily when navigating. It’s a pleasure to see wonderful sites like for which people worked carefully and with a clear strategy.

mball.cz

mball.cz - Awesome New Website Designs To Inspire You

drivingfutures.com

drivingfutures.com - Awesome New Website Designs To Inspire You

iamyuna.com

iamyuna.com - Awesome New Website Designs To Inspire You

beautifulexplorer.com

beautifulexplorer.com - Awesome New Website Designs To Inspire You

pixfx.at

pixfx.at - Awesome New Website Designs To Inspire You

donq.com

donq.com - Awesome New Website Designs To Inspire You

teixido.co

teixido.co - Awesome New Website Designs To Inspire You

orangecinemaseries.fr

orangecinemaseries.fr - Awesome New Website Designs To Inspire You

hyperakt.com

hyperakt.com - Awesome New Website Designs To Inspire You

wingcheng.com

wingcheng.com - Awesome New Website Designs To Inspire You

pointlesscorp.com

pointlesscorp.com - Awesome New Website Designs To Inspire You

goslingo.com

goslingo.com - Awesome New Website Designs To Inspire You

factoria.it

factoria.it - Awesome New Website Designs To Inspire You

dodocase.com

dodocase.com - Awesome New Website Designs To Inspire You

wecreative.com.br

wecreative.com.br - Awesome New Website Designs To Inspire You

haardtline.de

haardtline.de - Awesome New Website Designs To Inspire You

evilstudio.com

evilstudio.com - Awesome New Website Designs To Inspire You

inflicted.nl

inflicted.nl - Awesome New Website Designs To Inspire You

davidhellmann.com

davidhellmann.com - Awesome New Website Designs To Inspire You

humaan.com.au

humaan.com.au - Awesome New Website Designs To Inspire You

vgweb.com.br

vgweb.com.br - Awesome New Website Designs To Inspire You

foreverheavy.com

foreverheavy.com - Awesome New Website Designs To Inspire You

moovents.com

moovents.com - Awesome New Website Designs To Inspire You

infinvision.com

infinvision.com - Awesome New Website Designs To Inspire You

macaronibros.com

macaronibros.com - Awesome New Website Designs To Inspire You

robedwards.org

robedwards.org - Awesome New Website Designs To Inspire You

zenithdelille.com

zenithdelille.com - Awesome New Website Designs To Inspire You

flowacademy.pl

flowacademy.pl - Awesome New Website Designs To Inspire You

pixelot.de

pixelot.de - Awesome New Website Designs To Inspire You

vertaaverkkoja.fi

vertaaverkkoja.fi - Awesome New Website Designs To Inspire You

 

English: example of a data table with rollup f...

 

This tag is used to create table on the page. The component is rendered as an html element. UIColumn child components are responsible for rendering columns of the table. In these columns you can put any type of component like input text box, output text, command button etc.

<h:column> tag is used to create column. There can be many column tags within dataTable tag. You can set header and footer in this table. For this <f:facet> tag is used. data table component and its children column component can use header and footer facet.

 

 

We can associate this table element to backing bean. So we can obtain data from this backing bean and display it on the table. Association of backing bean can also be helpful for event handling purpose. Suppose we inserted command button in columns of the table then event handling can be applied here. If you want to customize the table then cascading stylesheet (CSS) can be used. This will help you to enhance the appearance of the table’s headers, footer, rows, columns.

 

This section provides you the code to which uses this tag and some of its attributes. It uses backing bean that supplies data to the data table to be rendered to the cells of the columns of the table.

code description :

 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<f:view><html><body>
<h:form>
<br><br><br>
<h:dataTable id="dt1" value="#{TableBean.perInfoAll}" var="item" bgcolor="#F1F1F1" border="10" cellpadding="5" cellspacing="3" first="0" rows="4" width="50%" dir="LTR" frame="hsides" rules="all" summary="This is a JSF code to create dataTable." >

<f:facet name="header">
<h:outputText value="This is 'dataTable' demo" />
</f:facet>

<h:column>
<f:facet name="header">
<h:outputText value="id" />
</f:facet>
<h:outputText value="#{item.id}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="name"/>
</f:facet>
<h:outputText value="#{item.name}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="phone"/>
</f:facet>
<h:outputText value="#{item.phone}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="city"/>
</f:facet>
<h:outputText value="#{item.city}"></h:outputText>
</h:column>

<h:column>
<f:facet name="header">
<h:outputText value="pin"/>
</f:facet>
<h:outputText value="#{item.pin}"></h:outputText>
</h:column>

<f:facet name="footer">
"The End" />
</f:facet>

</h:dataTable><br><br>

</h:form>
</body></html></f:view>

 

Rendered Output :

 



In this example we have used <h:dataTable> tag. This <h:dataTable> tag has many attributes to give form and shape to the table and getting data from backing bean’s attribute to display this data to the columns of the table. <f:facet> tag is used to create a header and a
footer for a dataTable component and it can create the same for columns also. So in this example we have used facet tag in dataTabe tag to create header and footer of the table component and in column tag also to create header for column. In this example, “This is ‘dataTable’ demo” is the header and “The End” is the footer for the table and “id” “name” “phone” “city” “pin” are headers for columns. In his example we have populated data to the table from bean named “TableBean”. It contains an attribute “perInfoAll” that is an array of objects of type “perInfo” class which contains some attributes like id, name, phone, city, pin that is to be displayed on the table. In the value attribute of dataTable tag, we have specified the binding expression to bind this component to the bean (
value="#{TableBean.perInfoAll}") and value specified in var attribute is used to populate data to the column of the table from attributes defined in class perInfo (value="#{item.id}"). The code for the bean has been given below (remember to specify it in faces-cocfig.xml file) :

 

public class TableBean {

private perInfo[] perInfoAll = new perInfo[]{
new perInfo(101, "CHANDAN", "9891444444", "aaa", 11111),
new perInfo(102, "RAVI", "9911666666", "bbb" ,22222),
new perInfo(103, "JOHN", "9313888888", "ccc", 33333),
new perInfo(104, "ANDREW", "9911222222", "ddd" , 44444),
new perInfo(105, "SYMONDS", "9313999999", "eee", 55555),
};

public perInfo[] getperInfoAll() {
return perInfoAll;
}

public class perInfo {
int id;
String name;
String phone;
String city;
int pin;

public perInfo(int id, String name, String phone, String city, int pin) {
this.id = id;
this.name = name;
this.phone = phone;
this.city = city;
this.pin= pin;
}

public int getid() {
return id;
}

public String getname() {
return name;
}

public String getphone() {
return phone;
}

public String getcity() {
return city;
}

public int getpin() {
return pin;
}

}

}

 

HTML Source Code:

 

<html>
     <body>
          <form id="_id0" method="post" action="/dt/data.jsf;jsessionid
=B95AF7B5F7D80BCB5638B91AC8154C33" enctype="application/x-www-form-urlencoded">
              <br><br><br>
		<table id="_id0:dt1" bgcolor="#F1F1F1" border="10"
 cellpadding="5" cellspacing="3" dir="LTR" frame="hsides" rules="all"
 summary="This is a JSF code to create dataTable." width="50%">
                    <thead>
                       <tr><th colspan="5" scope="colgroup">This is
 'dataTable' demo</th></tr>
                       <tr>
                          <th scope="col">id</th>
                          <th scope="col">name</th>
                          <th scope="col">phone</th>
                          <th scope="col">city</th>
                          <th scope="col">pin</th>
                       </tr>
                    </thead>
                    <tfoot>
                       <tr><td colspan="5">The End</td></tr>
                    </tfoot>
                    <tbody>
                        <tr>
                           <td>101</td>
                           <td>CHANDAN</td>
                           <td>9891444444</td>
                           <td>aaa</td>
                           <td>11111</td>
                        </tr>
                        <tr>
                           <td>102</td>
                           <td>RAVI</td>
                           <td>9911666666</td>
                           <td>bbb</td>
                           <td>22222</td>
                        </tr>
                        <tr>
                           <td>103</td>
                           <td>JOHN</td>
                           <td>9313888888</td>
                           <td>ccc</td>
                           <td>33333</td>
                        </tr>
                        <tr>
                           <td>104</td>
                           <td>ANDREW</td>
                           <td>9911222222</td>
                           <td>ddd</td>
                           <td>44444</td>
                        </tr>
                    </tbody>
                </table>
                <br><br>
		<input type="hidden" name="_id0" value="_id0" />
         </form>
    </body>
</html>

 

This tag has some attributes. These are listed below :

 

  • id : This is used to uniquely identify the table component. This must be unique within the closest parent component.
  • value : It represents the value of the component. It represents the value over which iteration is to be done. It may be an array or any iterator object .
  • var : This is the name of the variable created by the data table that represents the current item in the value. This attribute helps exposing the data in the rows of the table.
  • bgcolor : This attribute is used to set the background color for the table.
  • border : We can set the width of the table’s border around the table.
  • cellpadding : This sets the space between the content and the border of the cell.
  • cellspacing : It specifies the amount of space to leave between cells.
  • first : This is used to specify the row number of the first row from which displaying is to be started onwards. Suppose, this property is set to 3,displaying will be started from the third row of the underlying data.
  • rows : This attribute specifies the number of rows to display. This displaying will be started from the index specified in the “first” attribute. If we set this attribute to zero then all rows will be displayed.
  • width : This is used to set the width of the entire table. Its value is specified in %. Suppose we set it to 50% then this table will be shown in the 50% space of the width of your screen.
  • dir : This attribute indicates the direction of the text to be displayed in the cell. It takes “LTR” (left-to-right) and “RTL” (right-to-left) values. If we don’t specify this attribute then the content will be displayed in center.
  • frame : This attribute specifyes which sides of the frame surrounding this table will be visible. This attribute can take some values shown below :

 

  1. none  No side, Default Value
  2. above  Top side only
  3. below  Bottom side only
  4. hsides   Top and bottom sides only
  5. vsides   Right and left sides only
  6. lhs   Left hand side only
  7. rhs  Right hand side only
  8. box   All four sides 
  9. border  All four sides

 

  • rules : This attribute is used to draw lines between cells. It can take some values given below :
    1. none   No rules, default value
    2. groups  Between row groups
    3. rows   Between rows only
    4. cols  Between columns only
    5. all   Between all rows and columns
  • summary : You can specify summary of the purpose of the table.
  • rendered : It takes boolean value.This indicates whether or not this component should be rendered. Its default value is “true”. If it is set to false then it prevents rendering of this component to the page.
  • captionClass : Space separated list of CSS class or classes that will be applied to any caption generated for this table.
  • captionStyle : It specifies CSS style or styles to be applied when this caption is rendered.
  • columnClasses : Comma seperated list of CSS classes that will be applied to the columns of this table.
  • footerClass : This attribute takes Space-separated list of CSS style class or classes that will be applied to aheaderter generated for this table.
  • headerClass : This attribute takes Space-separated list of CSS style class or classes that will be
    applied to any header generated for this table.
  • rowClasses : It is a list of CSS classes applied to the rows of the table.These classes should be separated by comma. If we want to apply CSS class for individual rows then we can specify space separated list of CSS classes. Style classes are applied to rows in the same order that they are
    defined. If we have two CSS classes then first class is applied to the first row and the second one is applied to the second. Then again in the third row, the first CSS is applied and so on. This process goes on till the last row of the table. 
  • lang :  It sets the base language of an element?s attributes and text i.e. the language used in the generated markup for this component.
  • styleClass : It sets the name of CSS classor classes that is applied at the time of rendering the element.
  • title : The title attribute is used to set the tooltip text to display for the rendered  component.Tooltip describes an element when rendered to the client. 
  • binding : It is a value binding expression that is used to link component to a property in a backing bean.
  • onclick : It sets the JavaScript code to execute when a pointer button is clicked over this element.
  • ondblclick : It sets the JavaScript code to execute when a pointer button is double clicked over this element.
  • onkeydown : It sets the JavaScript code to execute when a key is pressed down over this element.
  • onkeypress : It sets the JavaScript code to execute when a key is pressed and released over this element.
  • onkeyup : It sets the JavaScript code to execute when a key is released over this element.
  • onmousedown : It sets the JavaScript code to execute when a pointer button is pressed down over this element.
  • onmousemove : It sets the JavaScript code to execute when a pointer button is moved within this element.
  • onmouseout : It sets the JavaScript code to execute when a pointer button is moved away from this element.
  • onmouseover : It sets the JavaScript code to execute when a pointer button is moved onto this element.
  • onmouseup : It sets the JavaScript code to execute when a pointer button is released over this element.

 

 

hi dear’s

I am caught in the problem that when i use “Form ENCTYPE=”multipart/form-data” and Method=”Post” and ACTION=”FileProcess.jsp” then i am get the file on FileProcess.jsp but i can’t get the other data

like example Problem Post by that Some Person

______________________________________________________________________________________________

http://www.velocityreviews.com/forums/t137597-html-file-upload-using-enctype-multipart-form-data-in-form.html

Should we use enctype=multipart/form-data in the form, I know it is recommended
if the form has <input type=”file”>. My form has and other
html controls.

I tried the following,

form.html
=========

POST” enctype=multipart/form-data>”

 

<input type=text name=”name” size=80>”

filename” size=80>”

<input type=”submit” value=”Upload File Test”>’
“</FORM>”

test.jsp
=========
<p><%= “filename = ” + request.getParameter(“filename”) %>
<p><%= “name = ” + request.getParameter(“name”) %>

It will output
filename = null
name = null

I don’t understand why, but if i remove enctype=multipart/form-data in the form,
then I am able to get the data.
Please advise. Thanks!!

_______________________________________________________________________________________________

Now i think you Have Clear Picture in Your Mind …….

Now i am going to tell you solution which i get From My RND and Try………..

1)Test.jsp

"!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
html
 "   head
script
             var e="";
function selValue(){
                //  alert('me there');
                e = document.getElementById("name");
                //   alert('me there ='+e);
                if(e=="")
                {
                    alert('Please Select');

                }else{

                    window.location.replace("Accountdetials.jsp?value="+e);
                }//  window.location="<%= request.getContextPath() + "/Test.jsp"%>"+"?value="+e;

            }
/script
<scriplet 
String selectedindex = "";

            String AccountStatus = request.getParameter("value");
            if (AccountStatus != null) {

                System.out.println("value=" + AccountStatus);
                session.setAttribute("AccountStatus", AccountStatus);

            } else {
                session.setAttribute("AccountStatus", null);
            }
/secriplet

body
FORM ENCTYPE="multipart/form-data" ACTION="FileProcess.jsp" METHOD=POST>

center>
table border="0" bgcolor=#ccFDDEE>
tr>UPLOAD THE FILE
tr> 
INPUT NAME="name" TYPE="text"
Choose the file To Upload:
INPUT NAME="file" TYPE="file"

input type="submit" value="Send File" 
table>
center> 
FORM>
BODY>
HTML>

 In above page you see one is <input and="" other="" input="" now="" when="" we="" use ="" "form="" enctype="multipart/form-data" then="" can't="" get="" data="" on="" page="" like="" that 
 boz now you data is send in multiparts for that reason we get file data like that which i tell in the below  FileProcess.jsp  now get the file data in the below page but not get the intput Type="text" data ..... now for that i use JAVASCRIPT like that now you can see the above Javascript function selValue(); then scriptlet of jsp how i put it in the session now when 
you press the Submit button the value of input text is all ready in the session .... now on next action jsp page just 
get that value from session 
I can do this on the Select Option tag ...... 

2)FileProcess.jsp

<scriplet
int totalRows = 0;
    String saveFile = "";
    String contentType = request.getContentType();
    if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
        DataInputStream in = new DataInputStream(request.getInputStream());
        System.out.println("dddda  === \n " + in.toString());
        int formDataLength = request.getContentLength();
        pi_filesize = formDataLength / 1024;        byte dataBytes[] = new byte[formDataLength];
        int byteRead = 0;
        int totalBytesRead = 0;
        while (totalBytesRead < formDataLength) {
            byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
            totalBytesRead += byteRead;
        }
        String file = new String(dataBytes);
        saveFile = file.substring(file.indexOf("filename=\"") + 10);
        //System.out.println(saveFile + "\t 1" + file.toString());
        saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
        // System.out.println(saveFile + "\t 2");
        saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
        // System.out.println(saveFile + "\t 3");
        int lastIndex = contentType.lastIndexOf("=");
        String boundary = contentType.substring(lastIndex + 1, contentType.length());
        int pos;
        pos = file.indexOf("filename=\"");
        pos = file.indexOf("\n", pos) + 1;
        pos = file.indexOf("\n", pos) + 1;
        pos = file.indexOf("\n", pos) + 1;
        int boundaryLocation = file.indexOf(boundary, pos) - 4;
        int startPos = ((file.substring(0, pos)).getBytes()).length;
        int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
        // saveFile = "C:/" + saveFile;
        File f = new File(saveFile);
        FileOutputStream fileOut = new FileOutputStream(f);
        fileOut.write(dataBytes, startPos, (endPos - startPos));
        fileOut.flush();
        fileOut.close();
/scripletI hope that will help you alot ...... any issue plz ask ............

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Now there is an other solution for you …. and i recommand you to use that ……

JSP NAME:

index.jsp

<html>
<head><title>Upload page</title></head></p> <p><body>
<form action=”employee_upload_profile_image.jsp” method=”post” enctype=”multipart/form-data” name=”form1″ id=”form1″>
<center>
<table border=”2″>
<tr>
<td align=”right”><b>Employee Name:</td>
<input type=”text” name=”emp_name”>
</tr>
<tr>
<td align=”right”><b>Employee Address:</td>
<input type=”text” name=”address1″>

</tr>
<tr>
<td>
</td>
<td>
<input type=”text” name=”address2″>
</td>
</tr>
<tr>
<td align=”right”><b>Contact Number:</td>
<input type=”text” name=”contact_number”>
</tr>
<tr>
<td align=”right”><b>Employee Email ID:</td>
<input type=”text” name=”email_id”>
</tr>

<tr>
<td align=”right”><b>Employee Image </td>
<td>
<input name=”file” type=”file” id=”file”>
<td>
</tr>

<tr>
<td align=”center”>
<input type=”submit” name=”Submit” value=”Submit”/>
<input type=”reset” name=”Reset” value=”Reset”/>

</td>
</tr>
</table>
</center>
</form>
</body>
</html>

=================================

JSP NAME:

employee_upload_profile_image.jsp

<%@ page import=”java.util.List” %>
<%@ page import=”java.util.Iterator” %>
<%@ page import=”java.io.File” %>
<%@ page import=”org.apache.commons.fileupload.servlet.ServletFileUpload”%>
<%@ page import=”org.apache.commons.fileupload.disk.DiskFileItemFactory”%>
<%@ page import=”org.apache.commons.fileupload.*”%>
<%@ page contentType=”text/html;charset=UTF-8″ language=”java” %>

<center><h1>Your  Profile has been Uploaded</h1></center>
<%    String emp_name = “”;
int count1 = 0;

boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
}
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
String name = item.getFieldName();
String value = item.getString();
if (name.equals(“emp_name”)) {
emp_name = value;
count1 = 1;
}
} else {
try {
String itemName = item.getName();
File savedFile = new File(“D:/” + itemName);
item.write(savedFile);
if (count1 == 1) {
out.println(“<tr><td align=’left’><b>Name:</td><td><b>” + emp_name);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
%>
</td></tr></table></center>

and two jars

commons-fileupload-1.2.2.jar

commons-io-2.4.jar

 

The Greek lowercase omega (ω) character is use...

Reference Rose India.

This is detailed simple java code that how save image into mysql database. Before running this java code you need to create data base and table to save image in same database. In the example given below we have used database ‘mahendra’ and table ‘save_image’.

Structure of table ‘save_image’

First create database named ‘mahendra’ by query given below:

mysql> create database mahendra;

and create table by query given below:

CREATE TABLE save_image (             
              id int(5) NOT NULL auto_increment,  
              name varchar(25) default NULL,      
              city varchar(20) default NULL,      
              image blob,                         
              Phone varchar(15) default NULL,     
              PRIMARY KEY  (`id`)                   
 );

Save table ‘save_image‘ in database ‘mahendra‘. Before running this java code you need mysql connector jar in the jdk1.6.0_01./lib.

SaveImageToDatabase java file provides full code for uploading image in database.

SaveImageToDatabase.java

import java.sql.*;
import java.io.*;
class SaveImageToDatabase {
public static void main(String[] args) throws SQLException {
// declare a connection by using Connection interface 
Connection connection = null;
/* Create string of connection url within specified format with machine 
name, port number and database name. Here machine name id localhost 
and database name is mahendra. */
String connectionURL = "jdbc:mysql://localhost:3306/mahendra";
/*declare a resultSet that works as a table resulted by execute a specified 
sql query. */
ResultSet rs = null;
// Declare prepare statement.
PreparedStatement psmnt = null;
// declare FileInputStream object to store binary stream of given image.
FileInputStream fis;
try {
// Load JDBC driver "com.mysql.jdbc.Driver"
Class.forName("com.mysql.jdbc.Driver").newInstance();
/* Create a connection by using getConnection() method that takes 
parameters of string type connection url, user name and password to 
connect to database. */
connection = DriverManager.getConnection(connectionURL, "root", "root");
// create a file object for image by specifying full path of image as parameter.
File image = new File("C:/image.jpg");
/* prepareStatement() is used for create statement object that is 
used for sending sql statements to the specified database. */
psmnt = connection.prepareStatement
("insert into save_image(name, city, image, Phone) "+ "values(?,?,?,?)");
psmnt.setString(1,"mahendra");
psmnt.setString(2,"Delhi");
psmnt.setString(4,"123456");
fis = new FileInputStream(image);
psmnt.setBinaryStream(3, (InputStream)fis, (int)(image.length()));
/* executeUpdate() method execute specified sql query. Here this query 
insert data and image from specified address. */ 
int s = psmnt.executeUpdate();
if(s>0) {
System.out.println("Uploaded successfully !");
}
else {
System.out.println("unsucessfull to upload image.");
}
}
// catch if found any exception during rum time.
catch (Exception ex) {
System.out.println("Found some error : "+ex);
}
finally {
// close all the connections.
connection.close();
psmnt.close();
}
}
}

Output of the program:

Download Source Code

JQuery

Just about every website uses the regular navigation concepts we’re all used to. After awhile this can get pretty boring, especially for designers who thrive on creativity. While mimicking the OS X dock and stacks isn’t new, it’s certainly not common.

A few days ago, Jeffrey posted about a potential “outside the box” competition on ThemeForest to encourage authors to put on their creativity hats and design usable templates with “outside the box” creative designs. In this tutorial I’ll cover a few ways to do just that with OS X style docks and stacks navigation.
Sources and Credits

Before we get started, I want to give a shout out to a couple guys who came to the rescue when they heard my call for help on Twitter. Steve updated the stacks script by Harley from using jQuery 1.2.6 to use the current 1.3.2 release and Rey Bango from the jQuery team helped me fix a bug. They both jumped to the task within a couple minutes of my cry for help via Twitter. Thanks a ton guys! *Round of applause* 😀

Original Sources
“Adding to Our Leopard Desktop with jQuery” by Harley via Net.tutsplus.com
Interface: Fisheye Menu
jqDock v1.2
Example template (Internet Encyclopedia) by Luka Cvrk
Quick Notes

These scripts rely on jQuery 1.3.2. The examples shown are compatible with all major browsers including IE6 and are easy to ensure graceful degrading if JavaScript is off or disabled.
jQuery OS X Dock #1 (Horizontal)

The first dock we’ll build uses the jQuery Fisheye Menu plugin mentioned above. It’s pretty lightweight (~7kb with dependencies) but the main reason I wanted to use this one was because it’s incredibly smooth, no stuttering. View Demo.

As you can see in the demo, it’s incredibly smooth and responsive. The downside is that you can’t use fixed positioning with it if the page needs to scroll as it will break. If you don’t need it fixed within the browser window then it works great.

This is a great example of “outside the box” concepts in websites and provides an interactive and fun interface.

Required files (I’ve combined the Fisheye plugin and iutil.js in the demo files).
jQuery 1.3.2
Interface: Fisheye Menu plugin
Interface: iutil.js (dependency)
The HTML

We’ll wrap our images and titles in links and place them within a containing div. Then we’ll wrap it all in another containing div for it to function properly.
view plaincopy to clipboardprint?
<div id=”dock”>
<div>
<a href=”index.html”><span>Example 1</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/home.png&#8221; alt=”home”></a>
<a href=”example2.html”><span>Example 2</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/email.png&#8221; alt=”contact”></a>
<a href=”example3.html”><span>Example 3</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/portfolio.png&#8221; alt=”portfolio”></a>
<a href=”all-examples.html”><span>All Examples</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/music.png&#8221; alt=”music”></a>
<a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>Video</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/video.png&#8221; alt=”video”></a>
<a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>History</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/history.png&#8221; alt=”history”></a>
<a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>Calendar</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/calendar.png&#8221; alt=”calendar”></a>
<a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>Links</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/link.png&#8221; alt=”links”></a>
RSSrss
<a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>RSS2</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/rss2.png&#8221; alt=”rss”></a>
</div>

<!– end div .dock-container –>
</div>

<!– end div .dock #dock –>

Notice that I’ve placed the titles in span tags so we can style them as well as allow the plugin to hide/show them as necessary.
The CSS

With CSS we’ll position the dock where we want it on the page. We can’t use fixed positioning with this plugin or it won’t function properly.
.dock-container { position: relative; top: -8px; height: 50px; padding-left: 20px; }
a.dock-item { display: block; width: 50px; position: absolute; bottom: 0; text-align: center; text-decoration: none; color: #333; }
.dock-item span { display: none; padding-left: 20px; }
.dock-item img { border: 0; margin: 5px 10px 0px; width: 100%; }

I’ve also placed a little extra CSS in the head of the page below the CSS included above. I wrapped it in noscript tags in case a visitor doesn’t have JavaScript enabled or available, it will still be a usable navigation. I should point out that this will not validate because the noscript tag isn’t valid in the head section, even though it works in all the current browsers. 😉
#dock { top: -32px; }
a.dock-item { position: relative; float: left; margin-right: 10px; }
.dock-item span { display: block; }
The JavaScript

We’ll bring in our JavaScript files now starting with jQuery 1.3.2. The fisheye-iutil.min.js file is the combination of the Fisheye plugin and its dependent iutil.js file. We’ll create the last file and put our JavaScript necessary to initialize the dock in it.
view plaincopy to clipboardprint?
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js”></script&gt;
<script type=”text/javascript” src=”js/fisheye-iutil.min.js”></script>

Now we’ll initialize the dock once the page loads. You can use several plugin options to customize the dock as you need for positioning and functionality. You can view the documentation by visiting the site listed under sources for the Fisheye plugin.
view plaincopy to clipboardprint?
$(function () {
// Dock initialize
$(‘#dock’).Fisheye(
{
maxWidth: 30,
items: ‘a’,
itemsText: ‘span’,
container: ‘.dock-container’,
itemWidth: 50,
proximity: 60,
alignment : ‘left’,
valign: ‘bottom’,
halign : ‘center’
}
);
});

That’s all there is to it! 😀

jQuery OS X Dock #2 (Vertical)

The horizontal dock was easy and definitely a neat idea to use on websites. They’re probably the most common type used across the web currently so let’s try something different. We could get a little more “outside the box” if we did a vertical dock navigation.

This dock relies on the jqDock jQuery plugin. It’s approximately 10kb in size, so it’s a few kb larger than the previous version but that’s not much. The disadvantage to this plugin is that it’s not quite as smooth as the Fisheye plugin dock, although it’s still very fluid and certainly usable. This plugin also doesn’t have issues with fixed positioning. View Demo.
The HTML

We’ll put our images in an unordered list and wrap them in links. As with the last plugin, we’ll wrap everything within a containing div. When we initialize the plugin we’ll use the “ul” here.
view plaincopy to clipboardprint?
<div id=”dockContainer”>
<ul id=”jqDock”>
<li><a href=”index.html”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/home-sm.png&#8221; alt=”Home” title=”Example 1″></a></li>
<li><a href=”example2.html”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/email-sm.png&#8221; alt=”Contact” title=”Example 2″></a></li>
<li><a href=”example3.html”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/portfolio-sm.png&#8221; alt=”portfolio” title=”Example 3″></a></li>
<li><a href=”all-examples.html”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/music-sm.png&#8221; alt=”music” title=”All Examples”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/video-sm.png&#8221; alt=”video” title=”Video”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/history-sm.png&#8221; alt=”history” title=”History”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/calendar-sm.png&#8221; alt=”calendar” title=”Calendar”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/link-sm.png&#8221; alt=”links” title=”Links”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/rss-sm.png&#8221; alt=”rss” title=”RSS”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/dock/rss2-sm.png&#8221; alt=”rss” title=”RSS”></a></li>
</ul>
</div>

<!– end div #dockContainer –>

You’ll notice on this dock we don’t have titles wrapped in span tags. Instead, this plugin will look at the “title” tag set for each image and create the titles that way (if enabled in the plugin options). This makes the markup a little simpler but it also makes the titles a little less customizable.
The CSS

We position the dock on the left side (can be either side) using fixed positioning. We’ll give it a little space between itself and the top of the browser window for aesthetics and so the icons don’t disappear when enlarged.
#dockContainer { position: fixed; top: 60px; left: 6px; }
#jqDock { position: relative; bottom: 48px; }
.jqDockLabel { background: #333; color: #fff; padding: 3px 10px; -webkit-border-radius: 10px; -moz-border-radius: 10px; }

To style the titles we can use the “.jqDockLabel” class. We also won’t need to include any extra styles for it to still be usable with JavaScript disabled. It may not be very pretty but it’s functional.
The JavaScript

We’ll bring in the jQuery library just like the previous dock as well as the plugin.
view plaincopy to clipboardprint?
<script type=”text/javascript” src=”js/jquery.jqDock.min.js”></script>

We initialize the dock and set a few options to customize it. You can read the documentation on these settings by visiting the site listed under sources at the beginning of the tutorial for jqDock. What I want to point out here though is the duration option. This is the time for magnification animation in milliseconds. It’s nice to be able to change the duration speed but it seems to get a little stuttery, which is something I hate.
view plaincopy to clipboardprint?
$(function(){
var jqDockOpts = {align: ‘left’, duration: 200, labels: ‘tc’, size: 48, distance: 85};
$(‘#jqDock’).jqDock(jqDockOpts);
});

You can easily change the positioning of the dock and labels as well as the initial size of the icons and a few other options. What I didn’t like about this plugin is that it magnifies to the full size of the icon. The previous plugin gives you the ability to change the size it magnifies to. That’s all there is to it!

jQuery OS X Stack and Drop Stack

This is probably my favorite navigation style out of the three shown in this tutorial. It’s super lightweight (~1kb) and is a really creative “outside the box” method of navigation for a website. It might be a little awkward having the navigation in the bottom right or left of the browser window but it would certainly be creative and save lots of space. View Demo.

While writing this, I realized there are probably many people that won’t like their navigation at the bottom of the page so I took a couple extra minutes and added a drop-down stack to the example files. This way the navigation springs out from top to bottom so it can now be used at the top of pages.
View Demo.
The HTML

The HTML is just as simple as the two dock examples. We’ll place everything in a containing div and place all our images and titles, which are wrapped in links, within an unordered list.
view plaincopy to clipboardprint?
<div>
<img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/stack.png&#8221; alt=”stack”>
<ul id=”stack”>
<li><a href=””><span>Aperture</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/aperture.png&#8221; alt=”Aperature”></a></li>
<li><a href=”http://net.tutsplus.com/tutorials/javascript-ajax/jquery-os-x-style-dock-and-stack-navigation/#”><span>All Examples</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/photoshop.png&#8221; alt=”Photoshop”></a></li>
<li><a href=”example3.html”><span>Example 3</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/safari.png&#8221; alt=”Safari”></a></li>
<li><a href=”example2.html”><span>Example 2</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/coda.png&#8221; alt=”Coda”></a></li>
<li><a href=”index.html”><span>Example 1</span><img src=”http://d2o0t5hpnwv4c1.cloudfront.net/358_jquery/images/stacks/finder.png&#8221; alt=”Finder”></a></li>
</ul>
</div>

<!– end div .stack –>

Notice that I’ve placed an image before the unordered list. This is the basket image that the rest of the icons will be stacked behind.
The CSS

We’ll position the main container and make sure the basket image has a higher z-index than the unordered list so everything stacks behind it. Also notice that I’ve given the basket image 35px of padding. This prevents the icons behind the basket from being clicked since the basket image is shorter than the icons. If you change the basket icon to something taller then you’ll need to also change the padding.
view plaincopy to clipboardprint?
.stack { position: fixed; bottom: 28px; right: 40px; }
.stack > img { position: relative; cursor: pointer; padding-top: 35px; z-index: 2; }
.stack ul { list-style: none; position: absolute; top: 5px; cursor: pointer; z-index: 1; }
.stack ul li { position: absolute; }
.stack ul li img { border: 0; }
.stack ul li span { display: none; }
.stack .openStack li span {
font-family: “Lucida Grande”, Lucida, Verdana, sans-serif;
display:block;
height: 14px;
position:absolute;
top: 17px;
right:60px;
line-height: 14px;
border: 0;
background-color:#000;
padding: 3px 10px;
border-radius: 10px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
color: #fcfcfc;
text-align: center;
text-shadow: #000 1px 1px 1px;
opacity: .85;
filter: alpha(opacity = 85);
}

/* IE Fixes */
.stack { _position: absolute; }
.stack ul { _z-index:-1; _top:-15px; }
.stack ul li { *right:5px; }

The titles wrapped in span tags are set to display:none so they’ll be hidden when the page loads.
The JavaScript

We’ll place the JavaScript in its own file since it’s more than a couple lines. When the image outside the unordered list (the basket) is clicked, it uses jQuery’s toggle function to animate the the list items and set their position based on the horizontal starting point + .75px then multiplied by 2. This gives us the nice curved spring action of the list items.

You could change the .75px or the multiplier (2) to customize how much it curves.
view plaincopy to clipboardprint?
$(function () {
// Stack initialize
var openspeed = 300;
var closespeed = 300;
$(‘.stack>img’).toggle(function(){
var vertical = 0;
var horizontal = 0;
var $el=$(this);
$el.next().children().each(function(){
$(this).animate({top: ‘-‘ + vertical + ‘px’, left: horizontal + ‘px’}, openspeed);
vertical = vertical + 55;
horizontal = (horizontal+.75)*2;
});
$el.next().animate({top: ‘-50px’, left: ’10px’}, openspeed).addClass(‘openStack’)
.find(‘li a>img’).animate({width: ’50px’, marginLeft: ‘9px’}, openspeed);
$el.animate({paddingTop: ‘0’});
}, function(){
//reverse above
var $el=$(this);
$el.next().removeClass(‘openStack’).children(‘li’).animate({top: ’55px’, left: ‘-10px’}, closespeed);
$el.next().find(‘li a>img’).animate({width: ’79px’, marginLeft: ‘0’}, closespeed);
$el.animate({paddingTop: ’35’});
});

// Stacks additional animation
$(‘.stack li a’).hover(function(){
$(“img”,this).animate({width: ’56px’}, 100);
$(“span”,this).animate({marginRight: ’30px’});
},function(){
$(“img”,this).animate({width: ’50px’}, 100);
$(“span”,this).animate({marginRight: ‘0’});
});
});

Then when the user clicks the basket image again it runs the next function which reverses what we just did. I then added some additional animation to the list items and their titles to give them a little more user feedback, which of course can easily be removed.

And there you have it! A simple and flexible OS X style stack navigation for your website. 😀 This script is also in the process of being converted into an easier to use plugin so keep an eye out for that.

One of the most handy (and cool) tricks a web developer could learn to use is collapsible DIVs. This allows you to make a page that will only show the user what they want to see. If they’re interested in some part of content, such as a “mail to friend” or an expanded definition, they could click a link or image and make the page dynamically grow in size to show that added bit of content.

This was inspired by some comments in a post on Aaron’s SEO Buzz Box, and while I think he might be looking for a slightly more advanced solution, it gave me the idea to type up this post.

There’s a few different bits of code we’ll use in this. First we’ll create a div we want to expand or contract. For example:

mydiv” style=”display:none”>

This is a test!
Can you see me?

Notice our tagging the div with a unique id. This allows our Javascript to be able to find it when we alter it’s visibility. We also added a style property, setting it’s display attribute to “none”, which makes that DIV hidden when the page loads originally.

Next we’ll create a link with some inline Javascript to hide or show our div. It’s quite a bit to take in at once, but don’t worry I’ll explain it in depth in a second. Here it is:
mydiv').style.display == 'none'){ document.getElementById('mydiv').style.display = 'block'; }else{ document.getElementById('mydiv').style.display = 'none'; }">Toggle Div Visibility Whew! It’s so complicated because it’s done with inline Javascript. I’ll show an alternate method that’s much cleaner a bit later. But first, let’s tackle this. It’s a simple anchor tag, but you’ll notice the href is “javascript:;”. The purpose of this is to basically do nothing. You don’t want to direct to any other page, and if you put everything in the onmousedown property in the href property, it would work the exact same, but the user would see a mess of javascript in his status bar when he moused over the link, so this keeps it cleaner. Another common do-nothing insert to use for the href property is a pound sign (#), and while that will work, it’ll also move the user’s scroll bar to the very top of your website, which can get quite annoying.

Note, the following explanation is very detailed and assumes virtually no knowledge of Javascript… so if this seems basic to you, feel free to skip it.

Now, we have the href property clean so there’s nothing ugly in the status bar on mouseover, but we still need to actually do the hiding or showing of the div. We call this through the onmousedown property of the anchor tag. We can find the DIV we created earlier by document.getElementById(‘mydiv’), so we decide to first check if it’s already visible or hidden by running a simple if-statement of if(document.getElementById(‘mydiv’).style.display == ‘none’){. If this returns true, meaning the display property is set to none (hidden), we continue past the first bracket and change it’s display property to “block”, which means visible. This will also create a line break before and after our div, so if you want it to appear in the middle of your text or other content, without line breaks, change “block” to “inline”. Following that setting statement, we have our else block, which it run if the first clause isn’t met (the display is NOT set to ‘none’). If it’s not set to none, we assume the div is visible, so we toggle it and hide the div, setting it’s display property to “none” (hidden) again.

An alternative which is a bit cleaner than that inline anchor tag (above) is creating a javascript function for toggling the DIV’s visibility. For this method, use the following anchor tag:
mydiv');">Toggle Div VisibilityThis anchor tag behaves like the above inline javascript, except instead of executing the change in the anchor tag itself (inline), it instead calls the toggleDiv function, passing the div name as a parameter.

This anchor tag above calls the following function. Simply insert this text (the function) somewhere in your document above the link in the body tag, or in the HEAD tag of the HTML itself:
<script language="javascript">
function toggleDiv(divid){
if(document.getElementById(divid).style.display == 'none'){
document.getElementById(divid).style.display = 'block';
}else{
document.getElementById(divid).style.display = 'none';
}
}
</script>
This function does exactly what the above inline javascript does, only it’s a bit cleaner. When it’s called by the anchor tag, it checks the div with the name passed to see if it’s currently not visible (display set to “none”), and if so, it shows it by changing the display to “block”. If the original if statement fails (display is not set to “none”), then it assumes the DIV is visible and hides it again (sets the display property to “none”).

Finally, here’s an example of it in action:

Toggle Div Visibility

Also note, search engines WILL read and index the content in these DIVs, so don’t worry about using collapsible DIVs hurting your SEO.

I can provide two ways,

a.jsp:

<html>
<script language="javascript" type="text/javascript">
function call(){
var name = "xyz";
window.location.replace("a.jsp?name="+name);
}
</script>
<input type="button" value="Get" onclick='call()'>
<%
String name=request.getParameter("name");
if(name!=null){
out.println(name);
}
%>
</html>

2)b.jsp:

<script>
var v="xyz";
</script>
<% String st="<script>document.writeln(v)</script>";
out.println("value="+st); %>