Saturday, 31 March 2012

Page Rendering


Pages are asked to render themselves only by IRequestTargets (see Request targets). So the initial message renderPage() comes from a target instance. Page render initiates render of all its subcomponents and is responsible for calling render related methods. Since page extends MarkupContainer most of its render logic is applicable to any MarkupContainer. Page rendering consists of the following steps:
  • before render step
  • rendering
  • after render step
It worth mentioning that before those steps page restores values of all form components which can be persisted (see FormComponent#supportsPersistence()). These values can be restored from anywhere (see IValuePersister interface). By default they are restored from cookies.
.......................................................................................
The renderNext() method belongs to MarkupContainer class and it is not used exclusively by pages. This method gets current tag from markup stream and attempts to find component which current markup tag corresponds to. Finding a component includes:
  • attempt to get component by id (value from "wicket:id" attribute) from the current markup container which is in case of rendering a page is page
  • attempt to find among parent markup containers the one that implements IComponentResolver interface and that can handle the current tag. This is used for example by Border component to resolve <wicket:body/> tag. In case of rendering a page there is no parent containers.
  • attempt to find IComponentResolver implementation registered at application level which can handle the current tag. These implementations include instances that handles all built-in wicket tags such as <wicket:extend>, <wicket:message> and others. You can add your implementation of IComponentResolver using Settings#addComponentResolver() method.
If component is found, it is asked to render itself by calling Component#render(MarkupStream) method (see Component rendering). Otherwise exception if thrown with a messages like "Unable to find component with id ... This means that you declared wicket:id ... in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match".
You should not change component state or change model during this step.

After render

After render step is similar to before render step. It includes:
  • calling onAfterRender() method for every component on the page
  • notifying all registered instances of IComponentOnAfterRenderListener (you can register a listener using Application#addComponentOnAfterRenderListener() method)
Unlike before render step these actions will be applied for all components whether there are visible or not. As a MarkupContainer page calls MarkupContainer#onAfterRenderChildren() and process all of its immediate subcomponents.
You should not change component state or change model during this step.


1) Create Table query
create table emp(eid number(20),ename varchar2(20),sal number(5))

2) Display nth highest salary from table :

SELECT DISTINCT (a.salary) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.salary)) FROM EMP B WHERE a.salary<=b.salary);

3) Versioning
select banner from v$version

4) Conversion :
select salary "Character",(to_char(to_date(salary,'j'), 'jsp')) "SALARYY" from emp

select ename "Name of Employees" from emp

JAVASCRIPT


Ways to implement JAVAScript
1 ) <script type="text/javascript" src="xxx.js"></script>
2 ) <script type ="text/javascript">
    function display() {
        document.write("<p>" + Date() + "</p>");
    }

</script>
    <title></title>
</head>

<body>
<button id  ="b1" runat ="server" onclick ="display()" value ="click">Click</button>

3) Semicolon is optional

JavaScript Statements

A JavaScript statement is a command to a browser. The purpose of the command is to tell the browser what to do.
This JavaScript statement tells the browser to write "Hello Dolly" to the web page:
document.write("Hello Dolly");
It is normal to add a semicolon at the end of each executable statement. Most people think this is a good programming practice, and most often you will see this in JavaScript examples on the web.
The semicolon is optional (according to the JavaScript standard), and the browser is supposed to interpret the end of the line as the end of the statement. Because of this you will often see examples without the semicolon at the end.

4)  Conditional Operator
<script type="text/javascript">

var visitor="PRES";
var greeting=(visitor=="PRES")?"Dear President ":"Dear ";
document.write(greeting);

</script>

5) Conditional
 <script type="text/javascript">
//Write a "Good morning" greeting if
//the time is less than 10

var d=new Date();
var time=d.getHours();

if (time<10)
  {
  document.write("<b>Good morning</b>");
  }
</script>
6)  Switch case

<script type="text/javascript">
//You will receive a different greeting based
//on what day it is. Note that Sunday=0,
//Monday=1, Tuesday=2, etc.

var d=new Date();
var theDay=d.getDay();
switch (theDay)
{
case 5:
  document.write("Finally Friday");
  break;
case 6:
  document.write("Super Saturday");
  break;
case 0:
  document.write("Sleepy Sunday");
  break;
default:
  document.write("I'm looking forward to this weekend!");
}
</script>
7) Confirm functionality
function show_confirm() {
        var r = confirm("Press a button");
        if (r == true) {
            alert("You pressed OK!");
        }
        else {
            alert("You pressed Cancel!");
        }
    }
8)  For….In
<html>
<body>
<script type="text/javascript">

var person={fname:"John",lname:"Doe",age:25};
var x;
for (x in person)
{
document.write(person[x] + " ");
}
</script>
</body>
</html>
Output : John Doe 25

Wednesday, 21 March 2012

Drop and Create to in SQL Server 2008

How to use  :
I will be writing about things I like from time to time. That is SQL Server things - other than beer, good books and company.
For today, one small thing but how useful. In SQL Server Management Studio 2008 you can script objects as DROP and CREATE in one go:

Why to use :
    This is very useful for us, as we store all database objects in our SVN as DROP..CREATE scripts. Using this feature saves quite a bit of time each time we want to update the source control.
I noticed an interesting behavior - if you script your table this way, all constraints defined in the table are scripted with drop statements before the actual DROP TABLE statement is included. This is quite handy as you can easily modify this script to change constraint names or definitions without having to script them separately.



How to DEBUG the Code ??

Basic steps  “ How to debug the code “
Steps :
1)      Put the breakpoint (Click on left-hand side of window ) Yellow colored line shows you are Compiling following line.Red Symbol showing your debugging started from that line



[Note : You can’t put breakpoint to GUI or presentation like .aspx file. Only in *.aspx.cs,*.cs etc  and you can’t put breakpoint for NAMESPACES]
1)      For Debugging you have some Important  shortcut keys like
F10 -  Start debugging
F11 – Go inside to the  Particular method when that yellow color available on that line

2)      When you  move your curser through objects,variables , methods etc its show description of that .


3)      When you start debugging again and again then , no need to stop process .Only just right click from where you  want to start debugging and click “SET NEXT STATEMENT”
That blue-mark …..


[These are basic steps of debugging .]
If you want to delete all breakpoint then go to

Debug -> Click on "Delete all breakpoint"

or

Double click on that breakpoint

  

Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

Actually we can't say that its a error .Its similar to exception that occured during URL Loading events.

Solution : Write like ths......   Make second argument of response.redirect(url,false);

Request.Redirect(url,false); 

Otherwise , no need to chnage in current scenario. It will not harm your code.
Just put in Try...Catch .
In Catch {Give name of Url you want to redirect...}




 

Tuesday, 20 March 2012

Know the inside of the third party library

When you developed java application and used the third party library. You want to know the inside of the third party library. You should attach the source for it. So an eclipse plugin to help you.

Use follwing plugins available on this link


Happy Coding !!!

Difference between Eval() And Bind() Methods

1 )  Eval is used for unidirectional (readonly) data binding, while Bind is for bi-directional (editable) databinding

2)  The Eval method is a static (read-only) method that takes the value of a data field and returns it as a string. The Bind method supports read/write functionality with the ability to retrieve the values of data-bound controls and submit any changes made back to the database.

3) If you bind a value using Eval, it is like a read only. You can only view the data.
If you bind a value using Bind, and if you do some change on the value it will reflect on the database also

4)  The Eval method evaluates late-bound data expressions in the templates of data-bound controls such as the GridView, DetailsView, and FormView controls. At run time, the Eval method calls the Eval method of the DataBinder object, referencing the current data item of the naming container. The naming container is generally the smallest part of the data-bound control that contains a whole record, such as a row in a GridView control. You can therefore use the Eval method only for binding inside templates of a data-bound control.
5)  The Eval method takes the name of a data field and returns a string containing the value of that field from the current record in the data source. You can supply an optional second parameter to specify a format for the returned string. The string format parameter uses the syntax defined for the Format method of the String class.

Sunday, 18 March 2012

SQL Connection Error 10053 : Event ID:17809 - Solution

Error Message : A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - An established connection was aborted by the software in your host machine.) (Microsoft SQL Server, Error: 10053) For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&EvtSrc=MSSQLServer&EvtID=10053&LinkId=20476

Event Log :

Could not connect because the maximum number of '2' user connections has already been reached. The system administrator can use sp_configure to increase the maximum value. The connection has been closed.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

First go to services and stop Service named SQL Server (MSSQLSERVER) Now Start both SQL Server (MSSQLSERVER) and SQL Server Agent (MSSQLSERVER)
Now you can connect to your database

Or you can increase the number of connections using sp_configure

Saturday, 17 March 2012

Microsoft's Newly added Namespaces

Communications and Workflow

System.ServiceModel.Syndication NEW
Atom10FeedFormatter NEW
Rss20FeedFormatter NEW
SyndicationFeed NEW
SyndicationItem NEW
System.ServiceModel.Web NEW
WebGetAttribute NEW
WebInvokeAttribute NEW
WebOperationContext NEW
WebServiceHost NEW

System.ServiceModel.Persistence NEW
PersistenceProvider NEW
PersistenceProviderFactory NEW
SqlPersistenceProviderFactory NEW
System.Net.PeerToPeer NEW
Cloud NEW
PeerName NEW
PeerNameRecord NEW
PeerNameResolver NEW
System.Net.PeerToPeer.Collaboration NEW
ContactManager NEW
PeerApplication NEW
PeerCollaboration NEW
PeerContact NEW
PeerNearMe NEW
------------------------------------------------------------------------------------

DATA, XML and LINQ

System.Data.Linq NEW
DataContext NEW
EntityRef<T>NEW
EntitySet<T>NEW
Table<T>NEW
System.Data.Linq.Mapping NEW
AttributeMappingSource NEW
Metamodel NEW
XmlMappingSource NEW

 
System.Xml.Linq NEW
XAttribute NEW
XDocument NEW
XElement NEW
XName NEW
XNamespace NEW
XNode NEW
XText NEW
---------------------------------------------------------------------------------------------------------------

ASP.NET

System.Web.ApplicationServices NEW
AuthenticationService NEW
ProfileService NEW
RoleService NEW
System.Web.Caching
Cache
System.Web.ClientServices NEW
ClientFormsIdentity NEW
ClientRolePrincipal NEW
ConnectivityStatus NEW
System.Web.ClientServices.Providers NEW
ClientFormsAuthenticationMembershipProvider NEW
ClientRoleProvider NEW
System.Web.Compilation
BuildProvider
System.Web.Configuration
WebConfigurationManager NEW
Fundamentals

DateTimeOffset NEW
TimeZoneInfo NEW
Type
Uri
System.AddIn.Contract NEW
IContract NEW
INativeHandleContract NEW
System.AddIn.Hosting NEW
AddInProcess NEW
AddInStore NEW
AddInSecurity NEW
AddInToken NEW
System.AddIn.Pipeline NEW
ContractBase NEW
ContractHandle NEW
CollectionAdapters NEW
FrameworkElementAdapters NEW

System.Collections.Generic
Dictionary<K,V>
HashSet<T> NEW

System.Diagnostics
Debug
EventLog
EventSchemaTraceListener NEW
Process
Trace
System.Diagnostics.Eventing NEW
EventDescriptor NEW
EventProvider NEW
EventProviderTraceListener NEW
System.Diagnostics.Eventing.Reader NEW

System.IO.Pipes NEW
AnonymousPipeClientStream NEW
AnonymousPipeServerStream NEW
NamedPipeClientStream NEW
NamedPipeServerStream NEW
PipeSecurity NEW
PipeStream NEW
System.IO.Ports
SerialPort
System.Linq NEW
IQueryable<T> NEW
Queryable NEW
System.Linq.Expressions NEW
Expression<T> NEW
Expression NEW

System.Runtime.Serialization.Json NEW
DataContractJsonSerializer NEW
JsonReaderWriterFactory NEW
System.Threading
ReaderWriterLockSlim NEW
EventLogInformation NEW
EventLogReader NEW
EventLogRecord NEW
EventLogWatcher NEW
EventRecord NEW
ProviderMetadata NEW
System.Diagnostics.PerformanceData NEW
CounterData NEW
CounterSet NEW
 
 

Thursday, 15 March 2012

Difference between an unsigned integer and signed integer (C Programming)?

Reserved word for integer is "int" in C programming, and reserved word for unsigned integer is "unsigned int".

int has a range of -32768 - 32767
unsigned int has a range of 0 - 65535

Wednesday, 14 March 2012

Simple web application for System.Data.OracleClient

using System.Data;using System.Data.OracleClient;namespace
{
OracleWebConnectivitypublic partial class _Default : System.Web.UI.Page{

{


cmd.CommandType =

protected void Page_Load(object sender, EventArgs e)OracleConnection conn = new OracleConnection("user id=xyz;password=****;data source=(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = serverName)(PORT = portAdds))(CONNECT_DATA = (SID = hoststring)))");OracleCommand cmd = new OracleCommand("Select empname from emp1", conn);CommandType.Text;//cmd.Parameters.AddWithValue("empname",empname);//cmd.Parameters.AddWithValue("empno",empno);conn.Open();
cmd.ExecuteNonQuery();


da.Fill(dt);

OracleDataAdapter da = new OracleDataAdapter(cmd);DataTable dt = new DataTable();foreach (DataRow row in dt.Rows)//Console.WriteLine(row["empname"] + "; " + row["empno"]); // this row for Console applicationlbl1.Text =

conn.Close();

}
}
}
" "+row["empname"];