TechnoBuzz

A Techno Blog, mainly about Java

Spring MVC refresher

web.xml:

application context Beans makeup the configuration of the root web application context
< context-param >
< param-name >contextConfigLocation< /param-name >
< param-value >/WEB-INF/accounts-application-config.xml< /param-value >
< /context-param >

Bootstraps the root web application context before servlet initialization
< listener >
< listener-class >org.springframework.web.context.ContextLoaderListener< /listener-class >
< /listener >

Deploys the dispatcher servlet along with its configuration
< servlet >
< servlet-name >accounts< /servlet-name >
< servlet-class >org.springframework.web.servlet.DispatcherServlet< /servlet-class >
< init-param >
< param-name >contextConfigLocation< /param-name >
< param-value >/WEB-INF/accounts-servlet-config.xml< /param-value >
< /init-param >
< /servlet >
accounts-servlet-config.xml:

< context:component-scan base-package=”accounts.web” />

< mvc:annotation-driven/ >

An interceptor which keeps a hibernate session open to allow lazy loading of backing object
< mvc:interceptors >
< bean class=”org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor” >
< property name=”sessionFactory” ref=”sessionFactory”/ >
< /bean >
< /mvc:interceptors >
< bean class=”org.springframework.web.servlet.view.InternalResourceViewResolver” >
< property name=”prefix” value=”/WEB-INF/views/”/ >
< property name=”suffix” value=”.jsp”/ >
< /bean >

Note: if had not have used component scanning would have had to wire up the controller

A Spring MVC @Controller

imports:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

package accounts.web;

@Controller
public class AccountController {

private AccountManager accountManager;

@ Autowired
public AccountController(AccountManager accountManager) {
this.accountManager = accountManager;
}

The method does not explicitly select a view name because the default
view name selected by Spring MVC matches to the incoming URL accountDetails.jsp
@ param id the id of the account
@ param model the “implicit” model created by Spring MVC

@ RequestMapping(“/accountDetails”)
public void accountDetails(@RequestParam(“entityId”) int id, Model model) {
model.addAttribute(“account”, accountManager.getAccount(id));
}

The method does not explicitly select a view name because the default
view name selected by Spring MVC matches to the incoming URL accountSummary.jsp

@ param model the “implicit” model created by Spring MVC

@ RequestMapping(“/accountSummary”)
public void accountSummary(Model model) {
model.addAttribute(“accounts”, accountManager.getAllAccounts());
}
}

index.html:

< a href=”accounts/accountSummary” >View Account Summary< /a >

http://localhost:8080/ss/accounts/accountSummary

Click on one of the listing entries

http://localhost:8080/ss/accounts/accountDetails?entityId=7

Again, this uses RequestParamin the nethod signature

public void accountDetails(@RequestParam(“entityId”) int id, Model model)

September 15, 2012 Posted by | IoC, Web Design | Leave a comment

iPhone5 w iOS6 launch

Wow factor? 4 ” screen, 4G LTE, new chargers needed, sleeker, no wireless charging, no NFC Wallet, A6. Sold 20x faster

Meanwhile, that new dock connector was so thoroughly leaked that it’s unlikely to put the wind up the burgeoning “appcessories” industry (yes, a word used seriously by real companies).

The Dev Centerhttps://developer.apple.com/technologies/ios6/

http://techcrunch.com/2012/09/12/the-loops-jim-dalrymple-apple-got-a-decade-head-start-on-most-people/

Very lightweight, more usable real estate, can operate with one hand, panoramic effect on side vertical view, fits in pocket

sweet spot on market with one device, upgraded components , a6, re-engineering camera, smaller camera, LTE,

Apple chose no NFC for now or step fwd on mobile payment system – punted for now. New passbook

iOS6 – developer pure performance, console quality graphics, google kicked out of platform, Map stuff is apple and google data is gone when upgraded, apple video instead of youtube.

iphone launch

Apple is not and will not change things just for the sake of change. And while some may now be clamoring for this change, the paradox is that if Apple did make some big changes, many of the same people would bitch and moan about them

 

September 15, 2012 Posted by | Uncategorized | Leave a comment