1>jsf页面js调试,手动添加debugger调试
方案:在页面中添加debugger,然后打开“开发者工具”(必须打开),直接运行页面自动跳转到debugger处。
2>jdeveloper使用svn版本控制,修改后版本控制异常
方案:使用jdeveloper集成的svn版本进行控制,经常出现版本控制异常,比如修改了几个问题,查看版本变动的时候
发现以前添加的文件都没有版本了,方法重新启动jdeveloper
3>jdeveloper使用svn版本控制,修改文件后查看挂起的更改,发现没有记录
方案:打开任意一个jdeveloper中的项目,然后再查看挂起的更改。
4>jdeveloper开发过程中,调试和运行可能突然中断,然后点击页面运行或调试,进入页面后直接卡死,紧接着weblogic直接终止运行或调试。
再次运行或是调试,weblgici始终无法启动,
方案:run>start server instance,先运行weblogci,然后再选择页面点击运行
5>无法验证事务处理中的所有行
运行项目报错:
javax.faces.el.EvaluationException: oracle.jbo.TxnValException: JBO-27023: 无法验证事务处理中的所有行。
出错原因:提交的字段的值没有通过验证
比如说:字段的长度过长,类型不匹配
注意:如果对数据库中的字段做修改,要与eo同步更改。
6>jdeveloper快捷键
ctrl+enter:输入sop然后按ctrl+enter,输出 System.out.println()
ctrl+enter:直接输入ctrl+enter,出来流程控制的智能提示
ctrl+j:删除本行
shift+enter:换行
ctrl+shift+上下方向键:向上或向下移动当前行代码
ctrl+shift+空格键:上下文智能提示
shift+alt+f:格式化
7>通用类ADFUtils和JSFUtils
1 package view; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 import javax.faces.model.SelectItem; 7 8 import oracle.adf.model.BindingContext; 9 import oracle.adf.model.binding.DCBindingContainer; 10 import oracle.adf.model.binding.DCIteratorBinding; 11 import oracle.adf.model.binding.DCParameter; 12 13 import oracle.adf.share.logging.ADFLogger; 14 15 16 17 import oracle.binding.AttributeBinding; 18 import oracle.binding.BindingContainer; 19 20 import oracle.binding.ControlBinding; 21 22 import oracle.binding.OperationBinding; 23 24 25 import oracle.jbo.ApplicationModule; 26 import oracle.jbo.Key; 27 import oracle.jbo.Row; 28 import oracle.jbo.uicli.binding.JUCtrlValueBinding; 29 30 31 /** 32 * A series of convenience functions for dealing with ADF Bindings. 33 * Note: Updated for JDeveloper 11 34 * 35 * @author Duncan Mills 36 * @author Steve Muench 37 * 38 * $Id: ADFUtils.java 2513 2007-09-20 20:39:13Z ralsmith $. 39 */ 40 public class ADFUtils { 41 42 public static final ADFLogger LOGGER = ADFLogger.createADFLogger(ADFUtils.class); 43 44 /** 45 * Get application module for an application module data control by name. 46 * @param name application module data control name 47 * @return ApplicationModule 48 */ 49 public static ApplicationModule getApplicationModuleForDataControl(String name) { 50 return (ApplicationModule)JSFUtils.resolveExpression("#{data." + name + 51 ".dataProvider}"); 52 } 53 54 /** 55 * A convenience method for getting the value of a bound attribute in the 56 * current page context programatically. 57 * @param attributeName of the bound value in the pageDef 58 * @return value of the attribute 59 */ 60 public static Object getBoundAttributeValue(String attributeName) { 61 return findControlBinding(attributeName).getInputValue(); 62 } 63 64 /** 65 * A convenience method for setting the value of a bound attribute in the 66 * context of the current page. 67 * @param attributeName of the bound value in the pageDef 68 * @param value to set 69 */ 70 public static void setBoundAttributeValue(String attributeName, 71 Object value) { 72 findControlBinding(attributeName).setInputValue(value); 73 } 74 75 /** 76 * Returns the evaluated value of a pageDef parameter. 77 * @param pageDefName reference to the page definition file of the page with the parameter 78 * @param parameterName name of the pagedef parameter 79 * @return evaluated value of the parameter as a String 80 */ 81 public static Object getPageDefParameterValue(String pageDefName, 82 String parameterName) { 83 BindingContainer bindings = findBindingContainer(pageDefName); 84 DCParameter param = 85 ((DCBindingContainer)bindings).findParameter(parameterName); 86 return param.getValue(); 87 } 88 89 /** 90 * Convenience method to find a DCControlBinding as an AttributeBinding 91 * to get able to then call getInputValue() or setInputValue() on it. 92 * @param bindingContainer binding container 93 * @param attributeName name of the attribute binding. 94 * @return the control value binding with the name passed in. 95 * 96 */ 97 public static AttributeBinding findControlBinding(BindingContainer bindingContainer, 98 String attributeName) { 99 if (attributeName != null) { 100 if (bindingContainer != null) { 101 ControlBinding ctrlBinding = 102 bindingContainer.getControlBinding(attributeName); 103 if (ctrlBinding instanceof AttributeBinding) { 104 return (AttributeBinding)ctrlBinding; 105 } 106 } 107 } 108 return null; 109 } 110 111 /** 112 * Convenience method to find a DCControlBinding as a JUCtrlValueBinding 113 * to get able to then call getInputValue() or setInputValue() on it. 114 * @param attributeName name of the attribute binding. 115 * @return the control value binding with the name passed in. 116 * 117 */ 118 public static AttributeBinding findControlBinding(String attributeName) { 119 return findControlBinding(getBindingContainer(), attributeName); 120 } 121 122 /** 123 * Return the current page's binding container. 124 * @return the current page's binding container 125 */ 126 public static BindingContainer getBindingContainer() { 127 return (BindingContainer)JSFUtils.resolveExpression("#{bindings}"); 128 } 129 130 /** 131 * Return the Binding Container as a DCBindingContainer. 132 * @return current binding container as a DCBindingContainer 133 */ 134 public static DCBindingContainer getDCBindingContainer() { 135 return (DCBindingContainer)getBindingContainer(); 136 } 137 138 /** 139 * Get List of ADF Faces SelectItem for an iterator binding. 140 * 141 * Uses the value of the 'valueAttrName' attribute as the key for 142 * the SelectItem key. 143 * 144 * @param iteratorName ADF iterator binding name 145 * @param valueAttrName name of the value attribute to use 146 * @param displayAttrName name of the attribute from iterator rows to display 147 * @return ADF Faces SelectItem for an iterator binding 148 */ 149 public static List<SelectItem> selectItemsForIterator(String iteratorName, 150 String valueAttrName, 151 String displayAttrName) { 152 return selectItemsForIterator(findIterator(iteratorName), 153 valueAttrName, displayAttrName); 154 } 155 156 /** 157 * Get List of ADF Faces SelectItem for an iterator binding with description. 158 * 159 * Uses the value of the 'valueAttrName' attribute as the key for 160 * the SelectItem key. 161 * 162 * @param iteratorName ADF iterator binding name 163 * @param valueAttrName name of the value attribute to use 164 * @param displayAttrName name of the attribute from iterator rows to display 165 * @param descriptionAttrName name of the attribute to use for description 166 * @return ADF Faces SelectItem for an iterator binding with description 167 */ 168 public static List<SelectItem> selectItemsForIterator(String iteratorName, 169 String valueAttrName, 170 String displayAttrName, 171 String descriptionAttrName) { 172 return selectItemsForIterator(findIterator(iteratorName), 173 valueAttrName, displayAttrName, 174 descriptionAttrName); 175 } 176 177 /** 178 * Get List of attribute values for an iterator. 179 * @param iteratorName ADF iterator binding name 180 * @param valueAttrName value attribute to use 181 * @return List of attribute values for an iterator 182 */ 183 public static List attributeListForIterator(String iteratorName, 184 String valueAttrName) { 185 return attributeListForIterator(findIterator(iteratorName), 186 valueAttrName); 187 } 188 189 /** 190 * Get List of Key objects for rows in an iterator. 191 * @param iteratorName iterabot binding name 192 * @return List of Key objects for rows 193 */ 194 public static List<Key> keyListForIterator(String iteratorName) { 195 return keyListForIterator(findIterator(iteratorName)); 196 } 197 198 /** 199 * Get List of Key objects for rows in an iterator. 200 * @param iter iterator binding 201 * @return List of Key objects for rows 202 */ 203 public static List<Key> keyListForIterator(DCIteratorBinding iter) { 204 List<Key> attributeList = new ArrayList<Key>(); 205 for (Row r : iter.getAllRowsInRange()) { 206 attributeList.add(r.getKey()); 207 } 208 return attributeList; 209 } 210 211 /** 212 * Get List of Key objects for rows in an iterator using key attribute. 213 * @param iteratorName iterator binding name 214 * @param keyAttrName name of key attribute to use 215 * @return List of Key objects for rows 216 */ 217 public static List<Key> keyAttrListForIterator(String iteratorName, 218 String keyAttrName) { 219 return keyAttrListForIterator(findIterator(iteratorName), keyAttrName); 220 } 221 222 /** 223 * Get List of Key objects for rows in an iterator using key attribute. 224 * 225 * @param iter iterator binding 226 * @param keyAttrName name of key attribute to use 227 * @return List of Key objects for rows 228 */ 229 public static List<Key> keyAttrListForIterator(DCIteratorBinding iter, 230 String keyAttrName) { 231 List<Key> attributeList = new ArrayList<Key>(); 232 for (Row r : iter.getAllRowsInRange()) { 233 attributeList.add(new Key(new Object[] { r.getAttribute(keyAttrName) })); 234 } 235 return attributeList; 236 } 237 238 /** 239 * Get a List of attribute values for an iterator. 240 * 241 * @param iter iterator binding 242 * @param valueAttrName name of value attribute to use 243 * @return List of attribute values 244 */ 245 public static List attributeListForIterator(DCIteratorBinding iter, 246 String valueAttrName) { 247 List attributeList = new ArrayList(); 248 for (Row r : iter.getAllRowsInRange()) { 249 attributeList.add(r.getAttribute(valueAttrName)); 250 } 251 return attributeList; 252 } 253 254 /** 255 * Find an iterator binding in the current binding container by name. 256 * 257 * @param name iterator binding name 258 * @return iterator binding 259 */ 260 public static DCIteratorBinding findIterator(String name) { 261 DCIteratorBinding iter = 262 getDCBindingContainer().findIteratorBinding(name); 263 if (iter == null) { 264 throw new RuntimeException("Iterator '" + name + "' not found"); 265 } 266 return iter; 267 } 268 269 /** 270 * @param bindingContainer 271 * @param iterator 272 * @return 273 */ 274 public static DCIteratorBinding findIterator(String bindingContainer, String iterator) { 275 DCBindingContainer bindings = 276 (DCBindingContainer)JSFUtils.resolveExpression("#{" + bindingContainer + "}"); 277 if (bindings == null) { 278 throw new RuntimeException("Binding container '" + 279 bindingContainer + "' not found"); 280 } 281 DCIteratorBinding iter = bindings.findIteratorBinding(iterator); 282 if (iter == null) { 283 throw new RuntimeException("Iterator '" + iterator + "' not found"); 284 } 285 return iter; 286 } 287 288 /** 289 * @param name 290 * @return 291 */ 292 public static JUCtrlValueBinding findCtrlBinding(String name){ 293 JUCtrlValueBinding rowBinding = 294 (JUCtrlValueBinding)getDCBindingContainer().findCtrlBinding(name); 295 if (rowBinding == null) { 296 throw new RuntimeException("CtrlBinding " + name + "' not found"); 297 } 298 return rowBinding; 299 } 300 301 /** 302 * Find an operation binding in the current binding container by name. 303 * 304 * @param name operation binding name 305 * @return operation binding 306 */ 307 public static OperationBinding findOperation(String name) { 308 OperationBinding op = 309 getDCBindingContainer().getOperationBinding(name); 310 if (op == null) { 311 throw new RuntimeException("Operation '" + name + "' not found"); 312 } 313 return op; 314 } 315 316 /** 317 * Find an operation binding in the current binding container by name. 318 * 319 * @param bindingContianer binding container name 320 * @param opName operation binding name 321 * @return operation binding 322 */ 323 public static OperationBinding findOperation(String bindingContianer, 324 String opName) { 325 DCBindingContainer bindings = 326 (DCBindingContainer)JSFUtils.resolveExpression("#{" + bindingContianer + "}"); 327 if (bindings == null) { 328 throw new RuntimeException("Binding container '" + 329 bindingContianer + "' not found"); 330 } 331 OperationBinding op = 332 bindings.getOperationBinding(opName); 333 if (op == null) { 334 throw new RuntimeException("Operation '" + opName + "' not found"); 335 } 336 return op; 337 } 338 339 /** 340 * Get List of ADF Faces SelectItem for an iterator binding with description. 341 * 342 * Uses the value of the 'valueAttrName' attribute as the key for 343 * the SelectItem key. 344 * 345 * @param iter ADF iterator binding 346 * @param valueAttrName name of value attribute to use for key 347 * @param displayAttrName name of the attribute from iterator rows to display 348 * @param descriptionAttrName name of the attribute for description 349 * @return ADF Faces SelectItem for an iterator binding with description 350 */ 351 public static List<SelectItem> selectItemsForIterator(DCIteratorBinding iter, 352 String valueAttrName, 353 String displayAttrName, 354 String descriptionAttrName) { 355 List<SelectItem> selectItems = new ArrayList<SelectItem>(); 356 for (Row r : iter.getAllRowsInRange()) { 357 selectItems.add(new SelectItem(r.getAttribute(valueAttrName), 358 (String)r.getAttribute(displayAttrName), 359 (String)r.getAttribute(descriptionAttrName))); 360 } 361 return selectItems; 362 } 363 364 /** 365 * Get List of ADF Faces SelectItem for an iterator binding. 366 * 367 * Uses the value of the 'valueAttrName' attribute as the key for 368 * the SelectItem key. 369 * 370 * @param iter ADF iterator binding 371 * @param valueAttrName name of value attribute to use for key 372 * @param displayAttrName name of the attribute from iterator rows to display 373 * @return ADF Faces SelectItem for an iterator binding 374 */ 375 public static List<SelectItem> selectItemsForIterator(DCIteratorBinding iter, 376 String valueAttrName, 377 String displayAttrName) { 378 List<SelectItem> selectItems = new ArrayList<SelectItem>(); 379 for (Row r : iter.getAllRowsInRange()) { 380 selectItems.add(new SelectItem(r.getAttribute(valueAttrName), 381 (String)r.getAttribute(displayAttrName))); 382 } 383 return selectItems; 384 } 385 386 /** 387 * Get List of ADF Faces SelectItem for an iterator binding. 388 * 389 * Uses the rowKey of each row as the SelectItem key. 390 * 391 * @param iteratorName ADF iterator binding name 392 * @param displayAttrName name of the attribute from iterator rows to display 393 * @return ADF Faces SelectItem for an iterator binding 394 */ 395 public static List<SelectItem> selectItemsByKeyForIterator(String iteratorName, 396 String displayAttrName) { 397 return selectItemsByKeyForIterator(findIterator(iteratorName), 398 displayAttrName); 399 } 400 401 /** 402 * Get List of ADF Faces SelectItem for an iterator binding with discription. 403 * 404 * Uses the rowKey of each row as the SelectItem key. 405 * 406 * @param iteratorName ADF iterator binding name 407 * @param displayAttrName name of the attribute from iterator rows to display 408 * @param descriptionAttrName name of the attribute for description 409 * @return ADF Faces SelectItem for an iterator binding with discription 410 */ 411 public static List<SelectItem> selectItemsByKeyForIterator(String iteratorName, 412 String displayAttrName, 413 String descriptionAttrName) { 414 return selectItemsByKeyForIterator(findIterator(iteratorName), 415 displayAttrName, 416 descriptionAttrName); 417 } 418 419 /** 420 * Get List of ADF Faces SelectItem for an iterator binding with discription. 421 * 422 * Uses the rowKey of each row as the SelectItem key. 423 * 424 * @param iter ADF iterator binding 425 * @param displayAttrName name of the attribute from iterator rows to display 426 * @param descriptionAttrName name of the attribute for description 427 * @return ADF Faces SelectItem for an iterator binding with discription 428 */ 429 public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding iter, 430 String displayAttrName, 431 String descriptionAttrName) { 432 List<SelectItem> selectItems = new ArrayList<SelectItem>(); 433 for (Row r : iter.getAllRowsInRange()) { 434 selectItems.add(new SelectItem(r.getKey(), 435 (String)r.getAttribute(displayAttrName), 436 (String)r.getAttribute(descriptionAttrName))); 437 } 438 return selectItems; 439 } 440 441 /** 442 * Get List of ADF Faces SelectItem for an iterator binding. 443 * 444 * Uses the rowKey of each row as the SelectItem key. 445 * 446 * @param iter ADF iterator binding 447 * @param displayAttrName name of the attribute from iterator rows to display 448 * @return List of ADF Faces SelectItem for an iterator binding 449 */ 450 public static List<SelectItem> selectItemsByKeyForIterator(DCIteratorBinding iter, 451 String displayAttrName) { 452 List<SelectItem> selectItems = new ArrayList<SelectItem>(); 453 for (Row r : iter.getAllRowsInRange()) { 454 selectItems.add(new SelectItem(r.getKey(), 455 (String)r.getAttribute(displayAttrName))); 456 } 457 return selectItems; 458 } 459 460 /** 461 * Find the BindingContainer for a page definition by name. 462 * 463 * Typically used to refer eagerly to page definition parameters. It is 464 * not best practice to reference or set bindings in binding containers 465 * that are not the one for the current page. 466 * 467 * @param pageDefName name of the page defintion XML file to use 468 * @return BindingContainer ref for the named definition 469 */ 470 private static BindingContainer findBindingContainer(String pageDefName) { 471 BindingContext bctx = getDCBindingContainer().getBindingContext(); 472 BindingContainer foundContainer = 473 bctx.findBindingContainer(pageDefName); 474 return foundContainer; 475 } 476 477 /** 478 * @param opList 479 */ 480 public static void printOperationBindingExceptions(List opList){ 481 if(opList != null && !opList.isEmpty()){ 482 for(Object error:opList){ 483 LOGGER.severe( error.toString() ); 484 } 485 } 486 } 487 }