| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
package org.kuali.rice.krad.uif.widget; |
| 12 | |
|
| 13 | |
import org.kuali.rice.krad.uif.UifConstants; |
| 14 | |
import org.kuali.rice.krad.uif.UifParameters; |
| 15 | |
import org.kuali.rice.krad.uif.container.View; |
| 16 | |
import org.kuali.rice.krad.uif.core.BindingInfo; |
| 17 | |
import org.kuali.rice.krad.uif.core.Component; |
| 18 | |
import org.kuali.rice.krad.uif.field.ActionField; |
| 19 | |
import org.kuali.rice.krad.uif.field.AttributeField; |
| 20 | |
import org.kuali.rice.krad.util.UrlFactory; |
| 21 | |
|
| 22 | |
import java.util.List; |
| 23 | |
import java.util.Map; |
| 24 | |
import java.util.Map.Entry; |
| 25 | |
import java.util.Properties; |
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
public class DirectInquiry extends Inquiry { |
| 33 | |
|
| 34 | |
private static final long serialVersionUID = -2490979579285984314L; |
| 35 | |
|
| 36 | |
private ActionField directInquiryActionField; |
| 37 | |
|
| 38 | |
|
| 39 | |
private String bindingPrefix; |
| 40 | |
|
| 41 | |
private boolean bindToMap; |
| 42 | |
|
| 43 | |
public DirectInquiry() { |
| 44 | 0 | super(); |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
@Override |
| 52 | |
public void performFinalize(View view, Object model, Component parent) { |
| 53 | 0 | super.performFinalize(view, model, parent); |
| 54 | |
|
| 55 | |
|
| 56 | 0 | if (!isRender() || isReadOnly()) { |
| 57 | 0 | return; |
| 58 | |
} |
| 59 | |
|
| 60 | |
|
| 61 | 0 | setRender(false); |
| 62 | |
|
| 63 | 0 | AttributeField field = (AttributeField) parent; |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | 0 | BindingInfo bindingInfo = field.getBindingInfo(); |
| 68 | 0 | if (bindingInfo.isBindToForm()) { |
| 69 | 0 | bindingPrefix = bindingInfo.getBindByNamePrefix(); |
| 70 | 0 | }else if (bindingInfo.isBindToMap()){ |
| 71 | 0 | bindToMap = true; |
| 72 | 0 | bindingPrefix = bindingInfo.getBindingObjectPath(); |
| 73 | |
}else{ |
| 74 | 0 | bindingPrefix = bindingInfo.getBindingObjectPath() + (bindingInfo.getBindByNamePrefix()==null?"":("." + bindingInfo.getBindByNamePrefix())); |
| 75 | |
} |
| 76 | |
|
| 77 | 0 | setupLink(view, model, field); |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
public void buildInquiryLink(Object dataObject, String propertyName, |
| 94 | |
Class<?> inquiryObjectClass, Map<String, String> inquiryParms) { |
| 95 | 0 | Properties urlParameters = new Properties(); |
| 96 | |
|
| 97 | 0 | urlParameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, |
| 98 | |
inquiryObjectClass.getName()); |
| 99 | 0 | urlParameters.put(UifParameters.METHOD_TO_CALL, |
| 100 | |
UifConstants.MethodToCallNames.START); |
| 101 | |
|
| 102 | |
|
| 103 | 0 | String inquiryUrl = UrlFactory.parameterizeUrl(getBaseInquiryUrl(), |
| 104 | |
urlParameters); |
| 105 | 0 | StringBuilder paramMapString = new StringBuilder(); |
| 106 | |
|
| 107 | 0 | String lightBoxOptions = ""; |
| 108 | 0 | boolean lightBoxShow = directInquiryActionField.getLightBox() != null; |
| 109 | 0 | if (lightBoxShow) { |
| 110 | 0 | lightBoxOptions = directInquiryActionField.getLightBox() |
| 111 | |
.getComponentOptionsJSString(); |
| 112 | |
} |
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | 0 | for (Entry<String, String> inquiryParameter : inquiryParms.entrySet()) { |
| 117 | 0 | if (bindToMap) { |
| 118 | 0 | paramMapString.append(bindingPrefix); |
| 119 | 0 | paramMapString.append("['"); |
| 120 | 0 | paramMapString.append(inquiryParameter.getKey()); |
| 121 | 0 | paramMapString.append("']"); |
| 122 | |
} else { |
| 123 | 0 | paramMapString.append(bindingPrefix); |
| 124 | 0 | paramMapString.append("."); |
| 125 | 0 | paramMapString.append(inquiryParameter.getKey()); |
| 126 | |
} |
| 127 | 0 | paramMapString.append(":"); |
| 128 | 0 | paramMapString.append(inquiryParameter.getValue()); |
| 129 | 0 | paramMapString.append(","); |
| 130 | |
} |
| 131 | 0 | paramMapString.deleteCharAt(paramMapString.length() - 1); |
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | 0 | StringBuilder onClickScript = new StringBuilder("showDirectInquiry(\""); |
| 136 | 0 | onClickScript.append(inquiryUrl); |
| 137 | 0 | onClickScript.append("\", \""); |
| 138 | 0 | onClickScript.append(paramMapString); |
| 139 | 0 | onClickScript.append("\", "); |
| 140 | 0 | onClickScript.append(lightBoxShow); |
| 141 | 0 | onClickScript.append(", "); |
| 142 | 0 | onClickScript.append(lightBoxOptions); |
| 143 | 0 | onClickScript.append(");"); |
| 144 | 0 | directInquiryActionField.setBlockValidateDirty(true); |
| 145 | 0 | directInquiryActionField.setClientSideJs(onClickScript.toString()); |
| 146 | |
|
| 147 | 0 | setRender(true); |
| 148 | 0 | } |
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
@Override |
| 154 | |
public List<Component> getNestedComponents() { |
| 155 | 0 | List<Component> components = super.getNestedComponents(); |
| 156 | |
|
| 157 | 0 | components.add(directInquiryActionField); |
| 158 | |
|
| 159 | 0 | return components; |
| 160 | |
} |
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
public ActionField getDirectInquiryActionField() { |
| 166 | 0 | return this.directInquiryActionField; |
| 167 | |
} |
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
public void setDirectInquiryActionField(ActionField directInquiryActionField) { |
| 173 | 0 | this.directInquiryActionField = directInquiryActionField; |
| 174 | 0 | } |
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
public String getBindingPrefix() { |
| 180 | 0 | return this.bindingPrefix; |
| 181 | |
} |
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
public void setBindingPrefix(String bindingPrefix) { |
| 187 | 0 | this.bindingPrefix = bindingPrefix; |
| 188 | 0 | } |
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
|
| 193 | |
public void setBindToMap(boolean bindToMap) { |
| 194 | 0 | this.bindToMap = bindToMap; |
| 195 | 0 | } |
| 196 | |
|
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
public boolean isBindToMap() { |
| 201 | 0 | return bindToMap; |
| 202 | |
} |
| 203 | |
|
| 204 | |
} |