Second use of design patterns (memorandum patterns), design patterns memos

Source: Internet
Author: User

Second use of design patterns (memorandum patterns), design patterns memos

Our company has a very awesome girl who is one of the core figures in our project team. I usually ask her if I don't understand anything. Just yesterday we discussed a caching issue, I think in the class, the reference variable defined with static is the cache (because it was called in the previous company), and she thinks this is not, but it only exists in the memory, this is just a member variable, so he thinks it can only be called a variable. What do you think is the name of the awesome big guys?

Let's talk about the code first:

Requirement: Due to the customer's response, every time a page is deleted or edited, it always jumps to the starting page and cannot be returned to the page before their operation, therefore, I hope to have a function that allows me to perform any operations on the current page. If this page is not closed, the query conditions and pages will be retained, just as before the operation.

Thought: this is still an option. The memorandum mode starts !!

Code:

Private static Map <String, Object> map = new HashMap <String, Object> (); // defines a memorandum.
  
Public void remenber (OdsXsXscb odsXsXscb) {// Intercept the memorandum of use code
String flag = request. getParameter ("search"); // If the queried flag has a value, it is null.
If (odsXsXscb. getId () = null & flag = null) {// if not found
OdsXsXscb param = (OdsXsXscb) map. get (ses. getId (); // value from the memo
If (param = null) {// if there is no value in the memo
OdsXsXscb. setException ("1"); // returns the default search condition value.
} Else {// if there is a value
OdsXsXscb = param; // obtain the value in the memo and give it to the parameter.
}
} Else {// If the query is in, do not perform any operation after saving the memorandum.
Map. put (ses. getId (), odsXsXscb );
}
}
@ RequestMapping (value = "clear ")
Public void crearParam (HttpSession ses ){
Map. remove (ses. getId (); // if the window is closed, the memo record is removed.
}

I think this mode is easy to use. The original idea is to splice the data to the end of the address when it is deleted or modified, and then use the input tag to receive the data using the search criteria, and then passed in to the background, pass the value will die ..
Since I used the memorandum model, we have all agreed that, even the younger sister who has been denying me, also praised me for my clear thinking,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.