Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Model example?

Status
Not open for further replies.

evergrean100

Technical User
Dec 1, 2006
115
US
I am trying to make sure I know what exactly is meant by the Model part of MVC design pattern.

Model is where you have the Business rules. For example if I had a Form in the Presentation part (JSP) that had a Field entry called Street and I only wanted the user to be able to enter one of three Streets then I could create a validation condition in my Model Bean Java class:
Code:
public mymethod()
{
if((Street.equals("StreetOne")  ||  (Street.equals("StreetTwo")) || (Street.equals("StreetThree"))  {
      //good selection 
}
else
{
      //invalid selection
}
}

mymethod() would be called in the Servlet Controller.
Would this be a good example of Model code and/or Business logic that would be located in a Java Bean?
 
The model is the data.
String street - or an ArrayList of Strings, or an adress, containing a street, or a list of adresses.

Instead of a list an array might be used, or a stack...

In Swing I would show a JComboBox to reflect a selection - for jsp there are similar things I guess - the J2EE-Forum is for JSP-related questions.

don't visit my homepage:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top