Thursday, July 19, 2012

PopUp In Java Script and CSS

Steps :-

If you want to create popup on the click of a link then you need to follow the following steps.

1. Create link in you HTML file.
    <div id="link">
        <a href="javascript:openPopUp('http://makecodeeasy.blogspot.in/')">Click Here For open popUp</a>
    </div>

2. Create a popUp by HTML and CSS.
    <div id="popup" class="popUpDisplay">
   <div class="popUpTitle">
    <span onClick="closePopUp()"><img alt="Close Popup" src="close.png"/></span>
   </div>
   <div class="data">
<h3>Welcome to Make Code Easy </h3>
<br>
For getting more knowledge click on Continue
<ul class="buttons">
<li><span class="button" onclick="window.open(link), closePopUp()">Continue</span></li>
<li><span class="button" id="Cancel" onClick="closePopUp()">Cancel</span></li>
</ul>
   </div>
</div>

3. Create CSS for divs
 

.popUpTitle {
    background-color: #000000;
    height: 40px;
    width: 100%;
}


.popUpTitle img {
    float: right;
    margin-right: 2px;
    margin-top: 5px;
}


.data {
    background-color: #FFFFFF;
    height: auto;
    overflow: hidden;
font-size: 14px;
    padding: 25px 25px 50px;
    width: auto;
}


.buttons li {
    cursor: pointer;
    float: left;
    height: 29px;
    margin-right: 15px;
    width: 134px;
}


span.button {
    background-color: #000000;
    color: #ffffff;
    font-size: 15px;
    font-weight: bold;
    padding: 8px 25px;
    text-align: center;
}


.popUpDisplay {
    display: none;
    position: absolute;
    width: 440px;
height: 300px;
    width: 440px;
    left: 250px;
    z-index: 1001;
}


.dimLayer {
    display: none;
    outline: 0px none;
    height: 100%;
    width: 100%;
    background: #A9A9A9;
    top: 0px;
    left: 0px;
    z-index: 900;
    position: absolute;
    opacity: 0.5;
    filter: alpha(opacity=50);
    -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
    -khtml-opacity: 0.5;
    -moz-opacity: 0.5;
}

4. Create Java Script methods
    <script type="text/javascript">
var link;
var element;
function openPopUp(url)
{
link = url;
element = document.getElementById("background");
element.style.display = "block";
element = document.getElementById("popup");
element.style.display = "block";

}


function closePopUp()
{
element = document.getElementById("popup");
element.style.display = "none";
element = document.getElementById("background");
element.style.display = "none";
}


</script>

5. When you click on link then popup opens.
6. Download the full example for checking the output.
 

Download Full Example
    

Wednesday, July 18, 2012

Spring Expression Language (SpEL)

SpEL

SpEL is an Expression Language that wire the values into beans properties using expression at runtime.

Features

  • Literal expressions :-
    Integer Number :-
    <property name="num" value="#{5}">  
    The #{} markers are a clue to Spring that the content that they contain is a SpEL expression.

    Floating-point numbers :-
    <property name="num" value="#{50.5}"/>

    Scientific notation :-
    <property name="num" value="#{2e5}"/>

    String :-
    <property name='str' value='#{"laptop"}'/>
  • Boolean :- 
    <property name="val" value="#{true}"/>
    <property name="val" value="#{false}"/>
  • Referencing Beans :-
    <property name="name" value="#{Employee}"/>
    This is same as :-
    <property name="name" ref="Employee"/>

    Referring another bean property :-
    <bean id="cars" class="com.proj.vehicleApp.Cars"> 
         <property name="speed" value="#{bike.speed}" />
    </bean>
    Call Method :-
    <bean id="cars" class="com.proj.vehicleApp.Cars">   
        <property name="speed" value="#{bike.getSpeed()}" />
    </bean>
  • Arithmetic   +, -, *, /, %, ^
  • Relational   <, >, ==, <=, >=, lt, gt, eq, le, ge
  • Logical and, or, not, |
  • Conditional ?: (ternary), ?: (Elvis)
  • Regular expression matches

Tuesday, July 17, 2012

MVC

MVC = Model-View-Controller
 Clearly separates business, navigation and presentation logic.
  • Controller :- Handles navigation logic and interacts with the service tier for business logic.
  • Models :- Models represent knowledge. A model could be a single object (rather uninteresting), or it could be some structure of objects.
  • View :- A view is a (visual) representation of its model. It would ordinarily highlight certain attributes of the model and suppress others. It is thus acting as a presentation filter.

Mock Object

Mock objects are a useful way to write unit tests for objects that act as mediators. Instead of calling the real domain objects, the tested object calls a mock domain object that merely asserts that the correct methods were called, with the expected parameters, in the correct order. However, when the tested object must create the domain object, we are faced with a problem. How does the tested object know to create a mock domain object instead of the true domain object? In this article, software consultants Alexander Day Chaffee and William Pietri present a refactoring technique to create mock objects based on the factory method design pattern.

Mock test for WebApplicationContext

Mock test for WebApplicationContext/WebApplicationContextUtils [get Spring Application Context by Mock ]

protected XmlWebApplicationContext m_webAppContext;
static final String[] CONFIG_FILE_LOCATIONS = { "classpath:datasource.xml", "classpath:applicationContext-test.xml" };
   
m_webAppContext = new XmlWebApplicationContext();        m_webAppContext.setConfigLocations(CONFIG_FILE_LOCATIONS);

// set the servlet context
// Create a new MockServletContext, using no base path and a //DefaultResourceLoader
// (i.e. the classpath root as WAR root).

MockServletContext servletCtx = new MockServletContext();

// the following line is used when fetching the web application //context using this servlet context
// @see //WebApplicationContextUtils#getWebApplicationContext(ServletContext)
           servletCtx.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, m_webAppContext);
m_webAppContext.setServletContext(servletCtx);

// load the beans after injecting dependencies
m_webAppContext.refresh();
m_webAppContext.registerShutdownHook();

UVVK7GDB3MNC

ShareThis