Tuesday, July 22, 2014

JSP:An Architecture

JSP Architecture
Web browser directly accesses the JSP page of web container. The JSP pages interact with the web container’s JavaBeans which represent the application model. When client sends request from a JSP page, the response is sent back to the client depending on the requests which are invoked by the client request. If response requires accessing the database, the JSP page uses JavaBeans to get data from the database.

Monday, July 21, 2014

JSP:A Overview

JavaServer Pages(TM) is a technology specified by Sun Microsystems as a convenient way of generating dynamic content in pages that are output by a Web application (an application running on a Web server). JSP enables us to separate the dynamic content of webpage from static presentation content. A JSP page consists of HTML tags and JSP tags. HTML tags are used to create static page content and JSP tags are used to add dynamic content to web pages.
Why JSP?
Some benefits are following:
1.Web pages created using JSP are portable and can be used across multiple platforms without making any changes.
2.JSP pages are automatically compiled by servers. Developers need to compile JSP pages when the source code of the JSP page is changed.
3.Most important benefit of JSP is the separation of business logic from presentation logic. JavaBeans contain business logic and JSP pages contain presentation logic. This separation makes an application created in JSP more secure and reusable.
4.It easily combines static templates like HTML or XML fragments.
5.Its environment provides compilation of pages automatically.
6.Servlets cannot be accessed directly whereas a JSP page can be accessed directly as a simple HTML page.


Saturday, February 8, 2014

Xml Binding using XmlDataProvider in WPF

There are several ways to achieve xml binding but we will discuss about XmlDataProvider.

XmlDataProvider provides Source and XPath properties.
Info.xml file










xmlBinding.xaml








UI Display
After pressing F5,we can see the below UI with all the information present in Info.xml file in DataGrid.

Sunday, January 19, 2014

ContextMenu Example in WPF

Menu
A Menu is normally we see at the top of the window.Each of them in those menus are MenuItems.
ContextMenu
It is similar to Menu that pops ups when we right click on something.It is contexted to what is clicked.
Example of ContextMenu

ContextMenuExample1.xaml














UI Display:
After right click on RichTextBox,we can see the Context Menu.

Difference between Grid, StackPanel, WrapPanel, DockPanel and Canvas in WPF

Grid
Grid is the default container where we can arrange the elements in table format.
StackPanel
By using StackPanel we can arrange the elements vertically or horizontally.We can arrange child elements in a panel without affecting the size of the lements.
WrapPanel
WrapPanel is same as StackPanel but it wraps the elements accordingly to size of the form.  The control in Wrap Panel is shifted to the next line automatically if the form size is getting changed.
DockPanel
DockPanel is used to place the control in exact location like as Left, Right, Top and Bottom.
If we not specify any position then control will occupy entire space on the container.
Canvas
Canvas is used to place the control by specifying the position in pixel format.We can use Canvas.Left, Canvas.Right,Canvas.Bottom and Canvas.Top.

Saturday, January 18, 2014

Actions on TextBox:Example1

TextChanged Event
This event occurs only when text in TextBox changes.

ActionOnTextBoxExample1.xaml



ActionOnTextBoxExample1.xaml
  .cs








UI Display.
After pressing F5,enter some text or update the text in TextBox,we can the see the messagebox.


 

PropertyDescriptor in WPF

It provides an abstraction of a property on a class.A description of a property consists of a name,its attributes,the components class associated with and the types of property.It provides a mechanism to listen to property changed events of the owner class of the actual property has INotifyPropertyChanged implemented.
It provides following properties and method
1.       Converter-It contains the TypeConverter for this property
2.       IsLocalizable-It indicates whether the property can be localized
3.       GetEditor-It returns an editor of the specified type.
It also provides following abstract properties and methods
1.       ComponentType
2.       IsReadOnly
3.       PropertyType
4.       CanResetValue
5.       GetValue
6.       ResetValue

Keyboard Attached Event in WPF

There is one namespaces named System.Windows.Input where keyboard class is defined.
Keyboard class represents the keyboard device which provides keyboard related events, method and properties that provides information about the state of the keyboard.Each of the events that keyboard defines is an attached event.
In order to receive keyboard input, the element must be Focusable.Most UIElement derived objects are Focusable and if not then set the Focusable property on the base element to true.
Some useful events KeyUp, KeyDown, PreviewKeyUp, PreviewKeyDown, GotkeyboardFocus and LostKeyboardFocus are attached events of keyboard class.

KeyUp: This event occurs when a key on the keyboard is released.
KeyDown: This event occurs when a key is pressed on the keyboard.
Preview KeyUp: This is a tunneling event corresponding to KeyUp event.
Preview KeyDown: This is a tunneling event corresponding to KeyDown event.
GotkeyboardFocus: This event occurs when an element receives keyboard focus.
LostkeyboardFocus: This event occurs when an element loses keyboard focus.

KeyboardEventExample1.xaml




KeyboardEventExample1.xaml.cs
















UI Display:
After Pressing F5, GotkeyboardFocus event get fired as shown below when we click in TextBox and hence Text’s Background color get changed to Green.












After losing focus on TextBox, LostkeyboardFocus event get fired when we click or move cursor to other window and Text’s Background color get changed to Red.












Notes:
1.       There can be only one element with keyboard focus on the entire desktop.
2.       Keyboard focus refers to the object that is receiving keyboard input.
3.       For StackPanel and Canvas, the default value of Focusable property is false.

Friday, January 17, 2014

IDataErrorInfo in WPF

IDataErrorInfo
It provides the functionality to provide a custom error information that a user interface can bind to  control.It facilitates an error message indicating what is wrong with the object.
It has two properties that expose the functionality of IDataErrorInfo interface.
1.      Error-It gets an error message indicating what is wrong with the object.
2.      Item-It gets an error message for the property with the given name.
It is present in System.ComponentModel namespace.

ListBox Example2 in WPF

ListBoxExample2.xaml









UI Display:
After pressing F5,











Now select any item in the listBox collection.After selecting anyone,we can get the number of characters in the item selected in the mentioned label control..

Copyright © Codingnodes,2014.All Rights Reserved.