#Exercise #Tracker #application #with #PhoneGap
Exercise Tracker application with PhoneGap. In this tutorial, the Track Workout page and complete the app by creating the History and Track Info pages.
Saving the GPS Data
When the user clicks the Stop Tracking button, we need to stop following their GPS location and save all of the GPS points that were recorded (tracking_data) into the database. We’ll also reset the text input box (in case they want to record another workout straight away) and we’ll display a message that we have stopped location tracking.
PhoneGap provides both browser-based Local Storage and a SQLite database as methods of storing data on the phone. The SQL database is a lot more powerful (due to the fact you can specify table schemas), but comes at the cost of code complexity. Local Storage is a simple key/value store that is easy to setup and use. Data is stored using the setItem(key, value) method, and retrieved using the getItem(key) method.
Read MOre
Logging in C# with log4net
There are some examples out there, but I’ve found that most of are either too complicated or are too specific.
In the end I decided that the only way to fix the problem is to write a general tutorial on Log4Net configuration myself.
In the end I decided that the only way to fix the problem is to write a general tutorial on Log4Net configuration myself.
Basics
Use NuGet to download and install the latest version of Log4Net.Config files
Now you need to configure Log4Net.Read More »
Blur Mask Filter in Android
Blur Mask Filter on Bitmap in Android
This takes a mask, and blurs its edge by the specified radius. Whether or or not to include the original mask, and whether the blur goes outside, inside, or straddles, the original mask’s border, is controlled by the Blur enum. package com.example.androiddrawbitmap; import java.io.FileNotFoundException; import android.net.Uri; import android.os.Bundle; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BlurMaskFilter; import android.graphics.Canvas;…Read More »
Creating a Mobile Event Calendar
Tags: android, conference location, GNU General Public License, Google, google maps, IOS, IPhone, Mobile Calendar, Mobile Event Calendar, mobile version, Open Source
This tutorial describes how to build an HTML5-based mobile calendar to track conferences and events that run on iOS and Android phones using a mobile version of dhtmlxScheduler (open source, GPL). At the end, users will be able to add and edit events, select the conference location on Google Maps, and see the events in day, month, or list views….
Read More »
Auto Load More Data On Page Scroll using Jquery and PHP
Auto Load More Data On Page Scroll using Jquery and PHP
Tags: Application programming interface, FAQs Help and Tutorials, FireFox, javascript, JQuery, languages, Loading More Results From Database Using jQuery Ajax, PHP, programming, Safari, scripts, Table (database), Unique key, Window On Scroll Load Contents in PHP MySql using jQuery
This tutorial about my favorite place Dzone like data loading while page scrolling down with jQuery and PHP. We have lots of data but can not display all. This script helps you to display little data and make faster your website.
Read More »
Enabling the Android Move To SD Card
This Android Quick Tip will show you how to allow your end-users to optionally save valuable device storage space by choosing to store your application on their removable SD card.
Final Result Preview
This tutorial will take an existing Android application and add the ability for the user to move the application to their SD card. This feature was introduced in Android 2.2, but does not require the application to use the Android 2.2 SDK as the minimum supported SDK version. Even your Android 1.5 application can use this feature.Step 1: Preparation
We begin this tutorial by obtaining the version of the phrasebook Android application used in a previous tutorial called . Download the source code if you want to perform these steps yourself, or just follow along and use these steps with your own Android applications.If the user has Android 2.2 installed on their device and you haven’t applied this tip, they’ll see a tantalizingly useful, yet grayed out, button when they try to move the application to their SD card. Developers must specifically enable this feature within their specific applications……
Read More »
Validate IP Address with Regular Expression
Validate IP Address with Regular Expression
Tags: IP address Validation, regular expression to Validate IP address, Validate IP address with regular expressionIP Address Regular Expression Pattern ^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\. ([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$ Description ^ #start of the line ( # start of group #1 [01]?\\d\\d? # Can be one or two digits. If three digits appear, it must start either 0 or 1 # e.g ([0-9], [0-9][0-9],[0-1][0-9][0-9]) | # …or 2[0-4]\\d # start with 2, follow by 0-4 and end with any digit (2[0-4][0-9]) |…
Read More »
Regular Expression For Password Validation
Regular Expression For Password
Tags: regular expression for password, regular expression pattern, Validate password with regular expressionPassword Regular Expression Pattern ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20}) Description ( # Start of group (?=.*\d) # must contains one digit from 0-9 (?=.*[a-z]) # must contains one lowercase characters (?=.*[A-Z]) # must contains one uppercase characters (?=.*[@#$%]) # must contains one special symbols in the list “@#$%” . # match anything with previous condition checking {6,20} # length at least 6 characters and…
Read More »
Struts 2 + Quartz 2 (Cron) jobs in Java
Struts 2 + Quartz 2 scheduler integration example Struts 2 didn’t comes with any ready “Struts2-Quartz.jar” like plugin, the hack is use a standard Servlet Listener to link both frameworks together. See the relationship Struts 2 <– (Listener)–> Quartz <—> Scheduler task In this tutorial, we show you how to integrate both Struts 2 and Quartz scheduler framework together. Tools…
Java People You Should Know About Them
Here are the top 8 Java people, they’re created frameworks, products, tools or books that contributed to the Java community, and changed the way of coding Java. P.S The order is based on my personal priority. 8. Tomcat & Ant Founder James Duncan Davidson, while he was software engineer at Sun Microsystems (1997–2001), created Tomcat Java-based web server, still widely…
Read More »
About Zeeshan Akhter
Helping Blog:
http://zeeshanakhter.com
Free Tutorial Website:
http://latest-tutorial.com
Facebook Page:
https://www.facebook.com/pages/Programming-Helper-Latest-Tutorials/338205329541849
Facebook Group:
Join Programming Helper & Latest Tutorials here:
Join Group
Google +:
https://plus.google.com/109587309242947455813/
LinkedIn:
pk.linkedin.com/in/zeeshanakhter/
Twitter:
https://twitter.com/latesttutorials
If you need urgent help then you can directly email us:
http://zeeshanakhter.com
Free Tutorial Website:
http://latest-tutorial.com
Facebook Page:
https://www.facebook.com/pages/Programming-Helper-Latest-Tutorials/338205329541849
Facebook Group:
Join Programming Helper & Latest Tutorials here:
Join Group
Google +:
https://plus.google.com/109587309242947455813/
LinkedIn:
pk.linkedin.com/in/zeeshanakhter/
Twitter:
https://twitter.com/latesttutorials
If you need urgent help then you can directly email us:
admin@latest-tutorial.com or zeeshanakhter2009@gmail.com
Java Design Patterns
Tags: Adapter Design Pattern in Java, Design Patterns in Java, Design Patterns: Elements of Reusable Object-Oriented Software, Facade Design Pattern in Java, Java Design Patterns, Observer Design Pattern in Java, Singleton Design Patterns in Java
Design
Patterns are best practices how to solve common know problems. This
article will give an overview of best practices in object-orientated
programming and has pointers to some design-pattern tutorials. Design
pattern in software development Design patterns are proven solutions
approaches to specific problems. A design pattern is not a framework and
is not directly deployed via code. Design Pattern…Pattern
Please see the following description for details on the design pattern.
- Adapter Design Pattern in Java
- Facade Design Pattern in Java
- Observer Design Pattern in Java
- Singleton Design Patterns in Java
Struts 2 Tutorial
Welcome to Part-4 of the 7-part series where we will go through different aspects for Struts2 Framework with some useful examples. In previous part we went through Struts2 Validation Framework. We saw how easy it is to integrate validation in your struts2 application.
In this part we will discuss about Tiles Framework and its Integration with Struts2. We will add Tiles support to our HelloWorld Struts application that we created in previous parts. I strongly recommend you to go through previous articles and download the source code of our sample application.
The above code configure Tiles listener in web.xml. An input configuration file /WEB-INF/tiles.xml is passed as argument. This file contains the Tiles definition for our web application.
Create a file tiles.xml in WEB-INF folder and copy following code into it.
Here in tiles.xml we have define a template baseLayout. This layout contains attributes such as Header, Title, Body, Menu and Footer. The layout is then extended and new definitions for Welcome page and Customer page is defined. We have override the default layout and changed the content for Body and Title.
Header.jsp
Menu.jsp
Footer.jsp
The struts.xml now defines a new Result type for Tiles. This result type is used in tag for different actions. Also note that we have define a new action customer-form. This is just an empty declaration to redirect user to Customer form page when she clicks Customer link from menu.
Struts 2 Tutorial List
- Part 1: Introduction to Struts 2 Framework
- Part 2: Create Hello World Application in Struts 2
- Part 3: Struts 2 Validation Framework Tutorial with Example
- Part 4: Struts 2 Tiles Plugin Tutorial with Example
- Part 5: Struts 2 Interceptors Tutorial with Example
- Part 6: Struts 2 File Upload and Save Example
- Part 7: Struts 2 Ajax Tutorial with Example
Introduction to Tiles 2
Nowadays, website are generally divided into pieces of reusable template that are being rendered among different web pages. For example a site containing header, footer, menu etc. This items remains same through out the website and give it a common look and feel. It is very difficult to hard code this in each and every webpage and if later a change is needed than all the pages needs to be modified. Hence we use templatization mechanism. We create a common Header, Footer, Menu page and include this in each page. Tiles Plugin allow both templating and componentization. In fact, both mechanisms are similar: you define parts of page (a “Tile”) that you assemble to build another part or a full page. A part can take parameters, allowing dynamic content, and can be seen as a method in JAVA language. Tiles is a templating system used to maintain a consistent look and feel across all the web pages of a web application. It increase the reusability of template and reduce code duplication. A common layout of website is defined in a central configuration file and this layout can be extended across all the webpages of the web application.Our Application Layout
Our goal is to add Header, Footer and Menu to our StrutsHelloWorld application. Following will be the layout of the same.Required JAR files
In order to add Tiles support to our Struts2 application, we will need few jar files. Following is the list of JARs in our example. Add these JARs in WEB-INF/lib folder.Configuring Tiles in web.xml
To configure Tiles, an entry for listener has to be made in web.xml. Open the web.xml from WEB-INF folder and add following code into it.01.
<
listener
>
02.
<
listener-class
>
03.
04.
org.apache.struts2.tiles.StrutsTilesListener
05.
</
listener-class
>
06.
</
listener
>
07.
<
context-param
>
08.
<
param-name
>tilesDefinitions</
param-name
>
09.
<
param-value
>/WEB-INF/tiles.xml</
param-value
>
10.
11.
</
context-param
>
01.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
02.
03.
<!--DOCTYPE tiles-definitions PUBLIC-->
04.
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
06.
<
tiles-definitions
>
07.
<
definition
name
=
"baseLayout"
template
=
"/BaseLayout.jsp"
>
08.
<
put-attribute
name
=
"title"
value
=
""
/>
09.
10.
<
put-attribute
name
=
"header"
value
=
"/Header.jsp"
/>
11.
<
put-attribute
name
=
"menu"
value
=
"/Menu.jsp"
/>
12.
13.
<
put-attribute
name
=
"body"
value
=
""
/>
14.
<
put-attribute
name
=
"footer"
value
=
"/Footer.jsp"
/>
15.
16.
</
definition
>
17.
<
definition
name
=
"/welcome.tiles"
extends
=
"baseLayout"
>
18.
<
put-attribute
name
=
"title"
value
=
"Welcome"
/>
19.
20.
<
put-attribute
name
=
"body"
value
=
"/Welcome.jsp"
/>
21.
</
definition
>
22.
<
definition
name
=
"/customer.tiles"
extends
=
"baseLayout"
>
23.
24.
<
put-attribute
name
=
"title"
value
=
"Customer Form"
/>
25.
<
put-attribute
name
=
"body"
value
=
"/Customer.jsp"
/>
26.
27.
</
definition
>
28.
<
definition
name
=
"/customer.success.tiles"
extends
=
"baseLayout"
>
29.
<
put-attribute
name
=
"title"
value
=
"Customer Added"
/>
30.
31.
<
put-attribute
name
=
"body"
value
=
"/SuccessCustomer.jsp"
/>
32.
</
definition
>
33.
</
tiles-definitions
>
Creating JSPs
We will define the template for our webapplication in a JSP file called BaseLayout.jsp. This template will contain different segments of web page (Header, Footer, Menu etc). Create 4 new JSP files BaseLayout.jsp, Header.jsp, Menu.jsp and Footer.jsp and copy following content in each of them. BaseLayout.jsp01.
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
02.
<!--DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"-->
03.
05.
<
html
>
06.
<
head
>
07.
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=UTF-8"
>
08.
<
title
><
tiles:insertAttribute
name
=
"title"
ignore
=
"true"
/></
title
>
09.
10.
</
head
>
11.
<
body
>
12.
<
table
border
=
"1"
cellpadding
=
"2"
cellspacing
=
"2"
align
=
"center"
>
13.
<
tr
>
14.
15.
<
td
height
=
"30"
colspan
=
"2"
><
tiles:insertAttribute
name
=
"header"
/>
16.
</
td
>
17.
</
tr
>
18.
19.
<
tr
>
20.
<
td
height
=
"250"
><
tiles:insertAttribute
name
=
"menu"
/></
td
>
21.
<
td
width
=
"350"
><
tiles:insertAttribute
name
=
"body"
/></
td
>
22.
23.
</
tr
>
24.
<
tr
>
25.
<
td
height
=
"30"
colspan
=
"2"
><
tiles:insertAttribute
name
=
"footer"
/>
26.
27.
</
td
>
28.
</
tr
>
29.
</
table
>
30.
</
body
>
31.
</
html
>
1.
<%@ page contentType="text/html; charset=UTF-8"%>
2.
3.
<%@ taglib prefix="s" uri="/struts-tags"%>
4.
<
h2
>Struts2 Example - ViralPatel.net</
h2
>
1.
<%@ page contentType="text/html; charset=UTF-8"%>
2.
3.
<%@ taglib prefix="s" uri="/struts-tags"%>
4.
<
s:a
href
=
"customer-form"
>Customer</
s:a
>
1.
<%@ page contentType="text/html; charset=UTF-8"%>
2.
3.
<%@ taglib prefix="s" uri="/struts-tags"%>
4.
Copyright © ViralPatel.net
Modifications in Struts.xml
In struts.xml we defined result tag which maps a particular action with a JSP page. Now we will modify it and map the result with Tiles. Following will be the content of struts.xml file.01.
<?
xml
version
=
"1.0"
encoding
=
"UTF-8"
?>
02.
03.
<!--DOCTYPE struts PUBLIC-->
04.
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
06.
07.
<
struts
>
08.
<
constant
name
=
"struts.enable.DynamicMethodInvocation"
09.
value
=
"false"
/>
10.
11.
<
constant
name
=
"struts.devMode"
value
=
"false"
/>
12.
<
constant
name
=
"struts.custom.i18n.resources"
13.
value
=
"ApplicationResources"
/>
14.
15.
<
package
name
=
"default"
extends
=
"struts-default"
namespace
=
"/"
>
16.
<
result-types
>
17.
<
result-type
name
=
"tiles"
18.
19.
class
=
"org.apache.struts2.views.tiles.TilesResult"
/>
20.
</
result-types
>
21.
<
action
name
=
"login"
22.
class
=
"net.viralpatel.struts2.LoginAction"
>
23.
24.
<
result
name
=
"success"
type
=
"tiles"
>/welcome.tiles</
result
>
25.
<
result
name
=
"error"
>Login.jsp</
result
>
26.
</
action
>
27.
28.
<
action
name
=
"customer"
29.
class
=
"net.viralpatel.struts2.CustomerAction"
>
30.
<
result
name
=
"success"
type
=
"tiles"
>/customer.success.tiles</
result
>
31.
32.
<
result
name
=
"input"
type
=
"tiles"
>/customer.tiles</
result
>
33.
</
action
>
34.
<
action
name
=
"customer-form"
>
35.
<
result
name
=
"success"
type
=
"tiles"
>/customer.tiles</
result
>
36.
37.
</
action
>
38.
</
package
>
39.
</
struts
>