001    /**
002     * Copyright 2005-2012 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.rice.krad.web.form;
017    
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    import org.apache.commons.lang.StringUtils;
022    import org.apache.log4j.Logger;
023    import org.kuali.rice.krad.inquiry.Inquirable;
024    import org.kuali.rice.krad.uif.UifConstants.ViewType;
025    import org.kuali.rice.krad.uif.view.InquiryView;
026    
027    /**
028     * Form class for <code>InquiryView</code> screens
029     *
030     * @author Kuali Rice Team (rice.collab@kuali.org)
031     */
032    public class InquiryForm extends UifFormBase {
033        private static final long serialVersionUID = 4733144086378429410L;
034    
035        private String dataObjectClassName;
036        private Object dataObject;
037    
038        private boolean redirectedInquiry;
039    
040        public InquiryForm() {
041            setViewTypeName(ViewType.INQUIRY);
042    
043            redirectedInquiry = false;
044        }
045    
046        /**
047         * Picks out business object name from the request to get retrieve a
048         * lookupable and set properties
049         */
050        @Override
051        public void postBind(HttpServletRequest request) {
052            super.postBind(request);
053    
054            if (StringUtils.isBlank(getDataObjectClassName())) {
055                setDataObjectClassName(((InquiryView) getView()).getDataObjectClassName().getName());
056            }
057        }
058    
059        /**
060         * Class name of the data object the inquiry will display
061         *
062         * <p>
063         * Used to set the data object class for the <code>Inquirable</code> which
064         * is then used to perform the inquiry query
065         * </p>
066         *
067         * @return String class name
068         */
069        public String getDataObjectClassName() {
070            return this.dataObjectClassName;
071        }
072    
073        /**
074         * Setter for the inquiry data object class name
075         *
076         * @param dataObjectClassName
077         */
078        public void setDataObjectClassName(String dataObjectClassName) {
079            this.dataObjectClassName = dataObjectClassName;
080        }
081    
082        /**
083         * Result data object for inquiry that will be display with the view
084         *
085         * @return Object object instance containing the inquiry data
086         */
087        public Object getDataObject() {
088            return this.dataObject;
089        }
090    
091        /**
092         * Setter for the inquiry data object
093         *
094         * @param dataObject
095         */
096        public void setDataObject(Object dataObject) {
097            this.dataObject = dataObject;
098        }
099    
100        /**
101         * Indicates whether the requested was redirected from the inquiry framework due to an external object
102         * request. This prevents the framework from performing another redirect check
103         *
104         * @return boolean true if request was a redirect, false if not
105         */
106        public boolean isRedirectedInquiry() {
107            return redirectedInquiry;
108        }
109    
110        /**
111         * Setter for the redirected request indicator
112         *
113         * @param redirectedInquiry
114         */
115        public void setRedirectedInquiry(boolean redirectedInquiry) {
116            this.redirectedInquiry = redirectedInquiry;
117        }
118    
119        /**
120         * <code>Inquirable</code>  instance that will be used to perform
121         * the inquiry
122         *
123         * @return Inquirable instance
124         */
125        public Inquirable getInquirable() {
126            return (Inquirable) getView().getViewHelperService();
127        }
128    
129    }