001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package movieadmin;
043:
044: import com.sun.data.provider.RowKey;
045: import com.sun.rave.web.ui.appbase.AbstractPageBean;
046: import com.sun.webui.jsf.component.Body;
047: import com.sun.webui.jsf.component.DropDown;
048: import com.sun.webui.jsf.component.Form;
049: import com.sun.webui.jsf.component.Head;
050: import com.sun.webui.jsf.component.Html;
051: import com.sun.webui.jsf.component.Hyperlink;
052: import com.sun.webui.jsf.component.ImageComponent;
053: import com.sun.webui.jsf.component.Label;
054: import com.sun.webui.jsf.component.Link;
055: import com.sun.webui.jsf.component.Message;
056: import com.sun.webui.jsf.component.Page;
057: import com.sun.webui.jsf.component.StaticText;
058: import com.sun.webui.jsf.model.SingleSelectOptionsList;
059: import javax.faces.FacesException;
060: import javax.faces.component.html.HtmlPanelGrid;
061: import javax.faces.event.ValueChangeEvent;
062: import movieslib.Movie;
063: import movieslib.MovieListDataProvider;
064: import movieslib.MovieListDataProvider;
065:
066: /**
067: * <p>Page bean that corresponds to a similarly named JSP page. This
068: * class contains component definitions (and initialization code) for
069: * all components that you have defined on this page, as well as
070: * lifecycle methods and event handlers where you may add behavior
071: * to respond to incoming events.</p>
072: */
073: public class Preview extends AbstractPageBean {
074: // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">
075: private int __placeholder;
076:
077: /**
078: * <p>Automatically managed component initialization. <strong>WARNING:</strong>
079: * This method is automatically generated, so any user-specified code inserted
080: * here is subject to being replaced.</p>
081: */
082: private void _init() throws Exception {
083: }
084:
085: private Page page1 = new Page();
086:
087: public Page getPage1() {
088: return page1;
089: }
090:
091: public void setPage1(Page p) {
092: this .page1 = p;
093: }
094:
095: private Html html1 = new Html();
096:
097: public Html getHtml1() {
098: return html1;
099: }
100:
101: public void setHtml1(Html h) {
102: this .html1 = h;
103: }
104:
105: private Head head1 = new Head();
106:
107: public Head getHead1() {
108: return head1;
109: }
110:
111: public void setHead1(Head h) {
112: this .head1 = h;
113: }
114:
115: private Link link1 = new Link();
116:
117: public Link getLink1() {
118: return link1;
119: }
120:
121: public void setLink1(Link l) {
122: this .link1 = l;
123: }
124:
125: private Body body1 = new Body();
126:
127: public Body getBody1() {
128: return body1;
129: }
130:
131: public void setBody1(Body b) {
132: this .body1 = b;
133: }
134:
135: private Form form1 = new Form();
136:
137: public Form getForm1() {
138: return form1;
139: }
140:
141: public void setForm1(Form f) {
142: this .form1 = f;
143: }
144:
145: private HtmlPanelGrid mainPanel = new HtmlPanelGrid();
146:
147: public HtmlPanelGrid getMainPanel() {
148: return mainPanel;
149: }
150:
151: public void setMainPanel(HtmlPanelGrid hpg) {
152: this .mainPanel = hpg;
153: }
154:
155: private HtmlPanelGrid navigationPanel = new HtmlPanelGrid();
156:
157: public HtmlPanelGrid getNavigationPanel() {
158: return navigationPanel;
159: }
160:
161: public void setNavigationPanel(HtmlPanelGrid hpg) {
162: this .navigationPanel = hpg;
163: }
164:
165: private HtmlPanelGrid genrePanel = new HtmlPanelGrid();
166:
167: public HtmlPanelGrid getGenrePanel() {
168: return genrePanel;
169: }
170:
171: public void setGenrePanel(HtmlPanelGrid hpg) {
172: this .genrePanel = hpg;
173: }
174:
175: private HtmlPanelGrid moviePanel = new HtmlPanelGrid();
176:
177: public HtmlPanelGrid getMoviePanel() {
178: return moviePanel;
179: }
180:
181: public void setMoviePanel(HtmlPanelGrid hpg) {
182: this .moviePanel = hpg;
183: }
184:
185: private Hyperlink returnLink = new Hyperlink();
186:
187: public Hyperlink getReturnLink() {
188: return returnLink;
189: }
190:
191: public void setReturnLink(Hyperlink h) {
192: this .returnLink = h;
193: }
194:
195: private StaticText title = new StaticText();
196:
197: public StaticText getTitle() {
198: return title;
199: }
200:
201: public void setTitle(StaticText st) {
202: this .title = st;
203: }
204:
205: private StaticText year = new StaticText();
206:
207: public StaticText getYear() {
208: return year;
209: }
210:
211: public void setYear(StaticText st) {
212: this .year = st;
213: }
214:
215: private ImageComponent image = new ImageComponent();
216:
217: public ImageComponent getImage() {
218: return image;
219: }
220:
221: public void setImage(ImageComponent ic) {
222: this .image = ic;
223: }
224:
225: private HtmlPanelGrid detailsPanel = new HtmlPanelGrid();
226:
227: public HtmlPanelGrid getDetailsPanel() {
228: return detailsPanel;
229: }
230:
231: public void setDetailsPanel(HtmlPanelGrid hpg) {
232: this .detailsPanel = hpg;
233: }
234:
235: private Label genre1 = new Label();
236:
237: public Label getGenre1() {
238: return genre1;
239: }
240:
241: public void setGenre1(Label l) {
242: this .genre1 = l;
243: }
244:
245: private DropDown genre = new DropDown();
246:
247: public DropDown getGenre() {
248: return genre;
249: }
250:
251: public void setGenre(DropDown dd) {
252: this .genre = dd;
253: }
254:
255: private Message message1 = new Message();
256:
257: public Message getMessage1() {
258: return message1;
259: }
260:
261: public void setMessage1(Message m) {
262: this .message1 = m;
263: }
264:
265: private Label label1 = new Label();
266:
267: public Label getLabel1() {
268: return label1;
269: }
270:
271: public void setLabel1(Label l) {
272: this .label1 = l;
273: }
274:
275: private Label label2 = new Label();
276:
277: public Label getLabel2() {
278: return label2;
279: }
280:
281: public void setLabel2(Label l) {
282: this .label2 = l;
283: }
284:
285: private Label label3 = new Label();
286:
287: public Label getLabel3() {
288: return label3;
289: }
290:
291: public void setLabel3(Label l) {
292: this .label3 = l;
293: }
294:
295: private Label label4 = new Label();
296:
297: public Label getLabel4() {
298: return label4;
299: }
300:
301: public void setLabel4(Label l) {
302: this .label4 = l;
303: }
304:
305: private StaticText detailsGenre = new StaticText();
306:
307: public StaticText getDetailsGenre() {
308: return detailsGenre;
309: }
310:
311: public void setDetailsGenre(StaticText st) {
312: this .detailsGenre = st;
313: }
314:
315: private StaticText detailsRating = new StaticText();
316:
317: public StaticText getDetailsRating() {
318: return detailsRating;
319: }
320:
321: public void setDetailsRating(StaticText st) {
322: this .detailsRating = st;
323: }
324:
325: private StaticText detailsLength = new StaticText();
326:
327: public StaticText getDetailsLength() {
328: return detailsLength;
329: }
330:
331: public void setDetailsLength(StaticText st) {
332: this .detailsLength = st;
333: }
334:
335: private StaticText detailsDescription = new StaticText();
336:
337: public StaticText getDetailsDescription() {
338: return detailsDescription;
339: }
340:
341: public void setDetailsDescription(StaticText st) {
342: this .detailsDescription = st;
343: }
344:
345: // </editor-fold>
346:
347: /**
348: * <p>Construct a new Page bean instance.</p>
349: */
350: public Preview() {
351: }
352:
353: /**
354: * <p>Callback method that is called whenever a page is navigated to,
355: * either directly via a URL, or indirectly via page navigation.
356: * Customize this method to acquire resources that will be needed
357: * for event handlers and lifecycle methods, whether or not this
358: * page is performing post back processing.</p>
359: *
360: * <p>Note that, if the current request is a postback, the property
361: * values of the components do <strong>not</strong> represent any
362: * values submitted with this request. Instead, they represent the
363: * property values that were saved for this view when it was rendered.</p>
364: */
365: @Override
366: public void init() {
367: // Perform initializations inherited from our superclass
368: super .init();
369: // Perform application initialization that must complete
370: // *before* managed components are initialized
371: // TODO - add your own initialiation code here
372:
373: // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
374: // Initialize automatically managed components
375: // *Note* - this logic should NOT be modified
376: try {
377: _init();
378: } catch (Exception e) {
379: log("Preview Initialization Failure", e);
380: throw e instanceof FacesException ? (FacesException) e
381: : new FacesException(e);
382: }
383:
384: // </editor-fold>
385: // Perform application initialization that must complete
386: // *after* managed components are initialized
387: // TODO - add your own initialization code here
388: }
389:
390: /**
391: * <p>Callback method that is called after the component tree has been
392: * restored, but before any event processing takes place. This method
393: * will <strong>only</strong> be called on a postback request that
394: * is processing a form submit. Customize this method to allocate
395: * resources that will be required in your event handlers.</p>
396: */
397: @Override
398: public void preprocess() {
399: }
400:
401: /**
402: * <p>Callback method that is called just before rendering takes place.
403: * This method will <strong>only</strong> be called for the page that
404: * will actually be rendered (and not, for example, on a page that
405: * handled a postback and then navigated to a different page). Customize
406: * this method to allocate resources that will be required for rendering
407: * this page.</p>
408: */
409: @Override
410: public void prerender() {
411: RowKey newRowToPreview = getRequestBean1().getPreviewRow();
412: if (newRowToPreview != null) {
413: getSessionBean1().getMovieListDataProvider().setCursorRow(
414: newRowToPreview);
415: }
416: if (this .genre.getSelected() == null) {
417: MovieListDataProvider dp = getSessionBean1()
418: .getMovieListDataProvider();
419: String selectedGenre = (String) dp.getValue(dp
420: .getFieldKey("genre"));
421: this .genre.setSelected(selectedGenre);
422: }
423: }
424:
425: /**
426: * <p>Callback method that is called after rendering is completed for
427: * this request, if <code>init()</code> was called (regardless of whether
428: * or not this was the page that was actually rendered). Customize this
429: * method to release resources acquired in the <code>init()</code>,
430: * <code>preprocess()</code>, or <code>prerender()</code> methods (or
431: * acquired during execution of an event handler).</p>
432: */
433: @Override
434: public void destroy() {
435: }
436:
437: /**
438: * <p>Return a reference to the scoped data bean.</p>
439: */
440: protected ApplicationBean1 getApplicationBean1() {
441: return (ApplicationBean1) getBean("ApplicationBean1");
442: }
443:
444: /**
445: * <p>Return a reference to the scoped data bean.</p>
446: */
447: protected RequestBean1 getRequestBean1() {
448: return (RequestBean1) getBean("RequestBean1");
449: }
450:
451: /**
452: * <p>Return a reference to the scoped data bean.</p>
453: */
454: protected SessionBean1 getSessionBean1() {
455: return (SessionBean1) getBean("SessionBean1");
456: }
457:
458: public String returnLink_action() {
459: // TODO: Process the action. Return value is a navigation
460: // case name where null will return to the same page.
461: return "page1";
462: }
463:
464: public void genre_processValueChange(ValueChangeEvent event) {
465: MovieListDataProvider dp = getSessionBean1()
466: .getMovieListDataProvider();
467: RowKey movieRowKey = dp.getCursorRow();
468: Movie movie = (Movie) dp.getObject(movieRowKey);
469: try {
470: getSessionBean1().reviseGenre(movie,
471: (String) genre.getSelected());
472: } catch (Exception e) {
473: error("Could not revise movie genre");
474: log("Could not revise genre of movie "
475: + (movie == null ? "(null movie)" : movie.getId()
476: .toString()) + ": " + e, e);
477: }
478: }
479: }
|