FortunesController.java 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. Copyright 2009-2010 Igor Polevoy
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. /**
  14. * @author Igor Polevoy: 12/18/13 9:11 PM
  15. */
  16. package app.controllers;
  17. import app.models.Fortune;
  18. import org.javalite.activeweb.AppController;
  19. import java.util.ArrayList;
  20. import java.util.Collections;
  21. import java.util.Date;
  22. import java.util.List;
  23. public class FortunesController extends AppController {
  24. public void index() {
  25. List<Fortune> dbFortunes = Fortune.findAll();
  26. List<Fortune> fortunes = new ArrayList<Fortune>(dbFortunes);
  27. fortunes.add((Fortune) Fortune.create("id", 0, "message", "Additional fortune added at request time."));
  28. Collections.sort(fortunes);
  29. view("fortunes", fortunes);
  30. render().noLayout();
  31. }
  32. }