Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
FindOwnersForm.java
Package: petclinic.rar [view]
Upload User: dezhong
Upload Date: 2022-08-10
Package Size: 167k
Code Size: 2k
Category:
Java Develop
Development Platform:
Java
- package org.springframework.samples.petclinic.web;
- import java.util.Collection;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.samples.petclinic.Clinic;
- import org.springframework.samples.petclinic.Owner;
- import org.springframework.stereotype.Controller;
- import org.springframework.ui.Model;
- import org.springframework.validation.BindingResult;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- /**
- * JavaBean Form controller that is used to search for <code>Owner</code>s by
- * last name.
- *
- * @author Juergen Hoeller
- * @author Ken Krebs
- */
- @Controller
- @RequestMapping("/findOwners.do")
- public class FindOwnersForm {
- private final Clinic clinic;
- @Autowired
- public FindOwnersForm(Clinic clinic) {
- this.clinic = clinic;
- }
- @RequestMapping(method = RequestMethod.GET)
- public String setupForm(Model model) {
- model.addAttribute("owner", new Owner());
- return "findOwners";
- }
- @RequestMapping(method = RequestMethod.POST)
- public String processSubmit(Owner owner, BindingResult result, Model model) {
- // find owners by last name
- Collection<Owner> results = this.clinic.findOwners(owner.getLastName());
- if (results.size() < 1) {
- // no owners found
- result.rejectValue("lastName", "notFound", "not found");
- return "findOwners";
- }
- if (results.size() > 1) {
- // multiple owners found
- model.addAttribute("selections", results);
- return "owners";
- }
- else {
- // 1 owner found
- owner = results.iterator().next();
- return "redirect:owner.do?ownerId=" + owner.getId();
- }
- }
- }