1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.exoplatform.wcm.webui.dialog;
18
19 import java.security.AccessControlException;
20 import java.util.ArrayList;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.Map;
24
25 import javax.jcr.AccessDeniedException;
26 import javax.jcr.ItemExistsException;
27 import javax.jcr.ItemNotFoundException;
28 import javax.jcr.Node;
29 import javax.jcr.NodeIterator;
30 import javax.jcr.RepositoryException;
31 import javax.jcr.Session;
32 import javax.jcr.Value;
33 import javax.jcr.lock.LockException;
34 import javax.jcr.version.VersionException;
35 import javax.portlet.PortletMode;
36
37 import org.exoplatform.ecm.resolver.JCRResourceResolver;
38 import org.exoplatform.ecm.webui.form.UIDialogForm;
39 import org.exoplatform.ecm.webui.selector.UISelectable;
40 import org.exoplatform.ecm.webui.tree.selectone.UIOneTaxonomySelector;
41 import org.exoplatform.ecm.webui.utils.DialogFormUtil;
42 import org.exoplatform.webui.form.UIFormMultiValueInputSet;
43 import org.exoplatform.portal.webui.util.Util;
44 import org.exoplatform.portal.webui.workspace.UIPortalApplication;
45 import org.exoplatform.resolver.ResourceResolver;
46 import org.exoplatform.services.cms.BasePath;
47 import org.exoplatform.services.cms.CmsService;
48 import org.exoplatform.services.cms.JcrInputProperty;
49 import org.exoplatform.services.cms.impl.DMSConfiguration;
50 import org.exoplatform.services.cms.impl.DMSRepositoryConfiguration;
51 import org.exoplatform.services.cms.link.LinkManager;
52 import org.exoplatform.services.cms.taxonomy.TaxonomyService;
53 import org.exoplatform.services.cms.templates.TemplateService;
54 import org.exoplatform.services.ecm.publication.PublicationPlugin;
55 import org.exoplatform.services.ecm.publication.PublicationService;
56 import org.exoplatform.services.jcr.RepositoryService;
57 import org.exoplatform.services.jcr.core.ManageableRepository;
58 import org.exoplatform.services.jcr.ext.hierarchy.NodeHierarchyCreator;
59 import org.exoplatform.services.log.ExoLogger;
60 import org.exoplatform.services.log.Log;
61 import org.exoplatform.services.wcm.core.NodeLocation;
62 import org.exoplatform.services.wcm.publication.PublicationDefaultStates;
63 import org.exoplatform.services.wcm.utils.WCMCoreUtils;
64 import org.exoplatform.wcm.webui.Utils;
65 import org.exoplatform.web.application.ApplicationMessage;
66 import org.exoplatform.webui.application.WebuiRequestContext;
67 import org.exoplatform.webui.application.portlet.PortletRequestContext;
68 import org.exoplatform.webui.config.annotation.ComponentConfig;
69 import org.exoplatform.webui.config.annotation.EventConfig;
70 import org.exoplatform.webui.core.UIApplication;
71 import org.exoplatform.webui.core.UIComponent;
72 import org.exoplatform.webui.core.UIPopupComponent;
73 import org.exoplatform.webui.core.UIPopupContainer;
74 import org.exoplatform.webui.core.lifecycle.UIFormLifecycle;
75 import org.exoplatform.webui.event.Event;
76 import org.exoplatform.webui.event.EventListener;
77 import org.exoplatform.webui.event.Event.Phase;
78 import org.exoplatform.webui.form.UIFormInput;
79 import org.exoplatform.webui.form.UIFormInputBase;
80 import org.exoplatform.webui.form.UIFormStringInput;
81 import org.exoplatform.ecm.webui.form.DialogFormActionListeners;
82
83
84
85
86
87
88
89 @ComponentConfig (
90 lifecycle = UIFormLifecycle.class,
91 events = {
92 @EventConfig(listeners = UIContentDialogForm.AddActionListener.class, phase = Phase.DECODE),
93 @EventConfig(listeners = UIContentDialogForm.RemoveReferenceActionListener.class,
94 confirm = "DialogFormField.msg.confirm-delete", phase = Phase.DECODE),
95 @EventConfig(listeners = UIContentDialogForm.SaveDraftActionListener.class),
96 @EventConfig(listeners = UIContentDialogForm.FastPublishActionListener.class),
97 @EventConfig(listeners = UIContentDialogForm.PreferencesActionListener.class),
98 @EventConfig(listeners = UIContentDialogForm.CloseActionListener.class),
99 @EventConfig(listeners = DialogFormActionListeners.RemoveDataActionListener.class, phase = Phase.DECODE),
100 @EventConfig(listeners = DialogFormActionListeners.ChangeTabActionListener.class, phase = Phase.DECODE)
101 }
102 )
103 public class UIContentDialogForm extends UIDialogForm implements UIPopupComponent, UISelectable {
104
105
106 public static final String CONTENT_DIALOG_FORM_POPUP_WINDOW = "UIContentDialogFormPopupWindow";
107
108
109 public static final String FIELD_TAXONOMY = "categories";
110
111
112 public static final String TAXONOMY_CONTENT_POPUP_WINDOW = "UIContentPopupWindow";
113
114
115 private static final Log LOG = ExoLogger.getLogger(UIContentDialogForm.class.getName());
116
117
118 private NodeLocation webcontentNodeLocation;
119
120
121 private List<String> listTaxonomy = new ArrayList<String>();
122
123
124 private List<String> listTaxonomyName = new ArrayList<String>();
125
126
127 private String template;
128
129
130
131
132
133
134
135 public List<String> getListTaxonomy() {
136 return listTaxonomy;
137 }
138
139
140
141
142
143
144 public List<String> getlistTaxonomyName() {
145 return listTaxonomyName;
146 }
147
148
149
150
151
152
153 public void setListTaxonomy(List<String> listTaxonomyNew) {
154 listTaxonomy = listTaxonomyNew;
155 }
156
157
158
159
160
161
162 public void setListTaxonomyName(List<String> listTaxonomyNameNew) {
163 listTaxonomyName = listTaxonomyNameNew;
164 }
165
166
167 private Class<? extends UIContentDialogPreference> preferenceComponent;
168
169
170
171
172
173
174 public NodeLocation getWebcontentNodeLocation() {
175 return webcontentNodeLocation;
176 }
177
178
179
180
181
182
183 public void setWebcontentNodeLocation(NodeLocation webcontentNodeLocation) {
184 this.webcontentNodeLocation = webcontentNodeLocation;
185 }
186
187
188
189
190
191
192 public Class<? extends UIContentDialogPreference> getPreferenceComponent() {
193 return preferenceComponent;
194 }
195
196
197
198
199
200
201 public void setPreferenceComponent(Class<? extends UIContentDialogPreference> preferenceComponent) {
202 this.preferenceComponent = preferenceComponent;
203 }
204
205
206
207
208
209
210 public UIContentDialogForm() throws Exception {
211 setActions(new String [] {"SaveDraft", "FastPublish", "Preferences", "Close"});
212 }
213
214
215
216
217
218
219
220
221
222 public void init(Node webcontent, boolean isAddNew) throws Exception {
223 NodeLocation webcontentNodeLocation = null;
224 if(webcontent.isNodeType("exo:symlink")) {
225 LinkManager linkManager = getApplicationComponent(LinkManager.class);
226 Node realNode = linkManager.getTarget(webcontent);
227 webcontentNodeLocation = NodeLocation.getNodeLocationByNode(realNode);
228 this.contentType = realNode.getPrimaryNodeType().getName();
229 this.nodePath = realNode.getPath();
230 setStoredPath(getParentPath(realNode));
231 } else {
232 webcontentNodeLocation = NodeLocation.getNodeLocationByNode(webcontent);
233 this.contentType = webcontent.getPrimaryNodeType().getName();
234 this.nodePath = webcontent.getPath();
235 setStoredPath(getParentPath(webcontent));
236 }
237 this.webcontentNodeLocation = webcontentNodeLocation;
238 this.repositoryName = webcontentNodeLocation.getRepository();
239 this.workspaceName = webcontentNodeLocation.getWorkspace();
240 this.isAddNew = isAddNew;
241 resetProperties();
242 TemplateService templateService = getApplicationComponent(TemplateService.class) ;
243 String userName = Util.getPortalRequestContext().getRemoteUser();
244 this.template = templateService.getTemplatePathByUser(true, contentType, userName);
245 initFieldInput();
246 }
247
248 private String getParentPath(Node node) throws RepositoryException {
249 return node.getPath().substring(0, node.getPath().lastIndexOf('/'));
250 }
251
252
253
254
255
256
257 private void initFieldInput() throws Exception {
258 TemplateService tservice = this.getApplicationComponent(TemplateService.class);
259 List<String> documentNodeType = tservice.getDocumentTemplates();
260 if(!documentNodeType.contains(this.contentType)){
261 return;
262 }
263 if (!isAddNew) {
264 TaxonomyService taxonomyService = getApplicationComponent(TaxonomyService.class);
265 Node currentNode = getCurrentNode();
266 List<Node> listCategories = taxonomyService.getAllCategories(currentNode);
267 for (Node itemNode : listCategories) {
268 String categoryPath = itemNode.getPath().replaceAll(getPathTaxonomy() + "/", "");
269 if (!listTaxonomy.contains(categoryPath)) {
270 listTaxonomy.add(categoryPath);
271 listTaxonomyName.add(categoryPath);
272 }
273 }
274 }
275 if(listTaxonomyName == null || listTaxonomyName.size() == 0) return;
276 UIFormMultiValueInputSet uiFormMultiValue = createUIComponent(UIFormMultiValueInputSet.class, null, null);
277 uiFormMultiValue.setId(FIELD_TAXONOMY);
278 uiFormMultiValue.setName(FIELD_TAXONOMY);
279 uiFormMultiValue.setType(UIFormStringInput.class);
280 uiFormMultiValue.setValue(listTaxonomyName);
281 addUIFormInput(uiFormMultiValue);
282 }
283
284
285
286
287
288
289 public Node getCurrentNode() {
290 return NodeLocation.getNodeByLocation(webcontentNodeLocation);
291 }
292
293
294
295
296 public String getTemplate() {
297 return template;
298 }
299
300
301
302
303
304
305
306 public ResourceResolver getTemplateResourceResolver(WebuiRequestContext context, String template) {
307 DMSConfiguration dmsConfiguration = getApplicationComponent(DMSConfiguration.class);
308 String workspace = dmsConfiguration.getConfig().getSystemWorkspace();
309 return new JCRResourceResolver(workspace);
310 }
311
312
313
314
315
316
317
318
319
320
321 static public class CloseActionListener extends EventListener<UIContentDialogForm> {
322
323
324
325
326 public void execute(Event<UIContentDialogForm> event) throws Exception {
327 UIContentDialogForm contentDialogForm = event.getSource();
328 if (Util.getUIPortalApplication().getModeState() == UIPortalApplication.NORMAL_MODE)
329 ((PortletRequestContext)event.getRequestContext()).setApplicationMode(PortletMode.VIEW);
330 Utils.closePopupWindow(contentDialogForm, CONTENT_DIALOG_FORM_POPUP_WINDOW);
331 }
332 }
333
334
335
336
337
338
339
340
341
342
343 static public class PreferencesActionListener extends EventListener<UIContentDialogForm> {
344
345
346
347
348 public void execute(Event<UIContentDialogForm> event) throws Exception {
349 UIContentDialogForm contentDialogForm = event.getSource();
350 UIPopupContainer popupContainer = Utils.getPopupContainer(contentDialogForm);
351 popupContainer.addChild(contentDialogForm);
352 contentDialogForm.setParent(popupContainer);
353 UIContentDialogPreference contentDialogPreference = null;
354 if (contentDialogForm.getPreferenceComponent() != null)
355 contentDialogPreference = contentDialogForm.createUIComponent(contentDialogForm.getPreferenceComponent(),
356 null,
357 null);
358 else
359 contentDialogPreference = contentDialogForm.createUIComponent(UIContentDialogPreference.class,
360 null,
361 null);
362
363 Utils.updatePopupWindow(contentDialogForm, contentDialogPreference, CONTENT_DIALOG_FORM_POPUP_WINDOW);
364 contentDialogPreference.init();
365 }
366 }
367
368
369
370
371
372
373
374
375
376
377 public static class SaveDraftActionListener extends EventListener<UIContentDialogForm> {
378
379
380
381
382 public void execute(Event<UIContentDialogForm> event) throws Exception {
383 UIContentDialogForm contentDialogForm = event.getSource();
384 try {
385 Node webContentNode = contentDialogForm.getNode();
386 if (!webContentNode.isCheckedOut()) {
387 webContentNode.checkout();
388 }
389 List<UIComponent> inputs = contentDialogForm.getChildren();
390 if (contentDialogForm.checkCategories(contentDialogForm)) {
391 Utils.createPopupMessage(contentDialogForm,
392 "UIContentDialogForm.msg.non-categories",
393 null,
394 ApplicationMessage.WARNING);
395 return;
396 }
397 Map<String, JcrInputProperty> inputProperties = DialogFormUtil.prepareMap(inputs,
398 contentDialogForm.getInputProperties(),
399 contentDialogForm.getInputOptions());
400 CmsService cmsService = contentDialogForm.getApplicationComponent(CmsService.class);
401 if (WCMCoreUtils.canAccessParentNode(webContentNode)) {
402 cmsService.storeNode(contentDialogForm.contentType,
403 webContentNode.getParent(),
404 inputProperties,
405 contentDialogForm.isAddNew);
406 } else {
407 cmsService.storeEditedNode(contentDialogForm.contentType,
408 webContentNode,
409 inputProperties,
410 contentDialogForm.isAddNew);
411 }
412
413 if (Util.getUIPortalApplication().getModeState() == UIPortalApplication.NORMAL_MODE) {
414 ((PortletRequestContext) event.getRequestContext()).setApplicationMode(PortletMode.VIEW);
415 }
416 Utils.closePopupWindow(contentDialogForm, CONTENT_DIALOG_FORM_POPUP_WINDOW);
417
418 } catch(LockException le) {
419 Object[] args = {contentDialogForm.getNode().getPath()};
420 Utils.createPopupMessage(contentDialogForm, "UIContentDialogForm.msg.node-locked", args, ApplicationMessage.WARNING);
421 } catch(AccessControlException ace) {
422 if (LOG.isWarnEnabled()) {
423 LOG.warn(ace.getMessage());
424 }
425 } catch (AccessDeniedException ade) {
426 Utils.createPopupMessage(contentDialogForm,
427 "UIDocumentInfo.msg.access-denied-exception",
428 null,
429 ApplicationMessage.WARNING);
430 } catch(VersionException ve) {
431 Utils.createPopupMessage(contentDialogForm, "UIDocumentForm.msg.in-versioning", null, ApplicationMessage.WARNING);
432 } catch(ItemNotFoundException item) {
433 Utils.createPopupMessage(contentDialogForm, "UIDocumentForm.msg.item-not-found", null, ApplicationMessage.WARNING);
434 } catch(RepositoryException repo) {
435 String key = "UIDocumentForm.msg.repository-exception";
436 if (ItemExistsException.class.isInstance(repo)) key = "UIDocumentForm.msg.not-allowed-same-name-sibling";
437 Utils.createPopupMessage(contentDialogForm, key, null, ApplicationMessage.WARNING);
438 } catch (NumberFormatException nfe) {
439 Utils.createPopupMessage(contentDialogForm,
440 "UIDocumentForm.msg.numberformat-exception",
441 null,
442 ApplicationMessage.WARNING);
443 } catch (Exception e) {
444 Utils.createPopupMessage(contentDialogForm,
445 "UIDocumentForm.msg.cannot-save",
446 null,
447 ApplicationMessage.WARNING);
448 }
449 }
450
451 }
452
453
454
455
456
457
458
459
460 private boolean checkCategories(UIContentDialogForm contentDialogForm) {
461 String[] categoriesPathList = null;
462 int index = 0;
463 if (contentDialogForm.isReference) {
464 UIFormMultiValueInputSet uiSet = contentDialogForm.getChild(UIFormMultiValueInputSet.class);
465 if ((uiSet != null) && (uiSet.getName() != null) && uiSet.getName().equals(FIELD_TAXONOMY)) {
466 List<UIComponent> listChildren = uiSet.getChildren();
467 StringBuffer sb = new StringBuffer();
468 for (UIComponent component : listChildren) {
469 UIFormStringInput uiStringInput = (UIFormStringInput) component;
470 if (uiStringInput.getValue() != null) {
471 String value = uiStringInput.getValue().trim();
472 sb.append(value).append(",");
473 }
474 }
475 String categoriesPath = sb.toString();
476 if (categoriesPath != null && categoriesPath.length() > 0) {
477 try {
478 if (categoriesPath.endsWith(",")) {
479 categoriesPath = categoriesPath.substring(0, categoriesPath.length() - 1).trim();
480 if (categoriesPath.trim().length() == 0) {
481 return true;
482 }
483 }
484 categoriesPathList = categoriesPath.split(",");
485 if ((categoriesPathList == null) || (categoriesPathList.length == 0)) {
486 return true;
487 }
488 for (String categoryPath : categoriesPathList) {
489 index = categoryPath.indexOf("/");
490 if (index < 0) {
491 return true;
492 }
493 }
494 } catch (Exception e) {
495 return true;
496 }
497 }
498 }
499 }
500 return false;
501 }
502
503
504
505
506
507
508
509
510
511
512 public static class FastPublishActionListener extends EventListener<UIContentDialogForm> {
513
514
515
516
517 public void execute(Event<UIContentDialogForm> event) throws Exception {
518 UIContentDialogForm contentDialogForm = event.getSource();
519 try{
520 Node webContentNode = contentDialogForm.getNode();
521 if (!webContentNode.isCheckedOut()) {
522 webContentNode.checkout();
523 }
524 List<UIComponent> inputs = contentDialogForm.getChildren();
525 if (contentDialogForm.checkCategories(contentDialogForm)) {
526 Utils.createPopupMessage(contentDialogForm,
527 "UIContentDialogForm.msg.non-categories",
528 null,
529 ApplicationMessage.WARNING);
530 return;
531 }
532 Map<String, JcrInputProperty> inputProperties = DialogFormUtil.prepareMap(inputs,
533 contentDialogForm.getInputProperties(),
534 contentDialogForm.getInputOptions());
535 CmsService cmsService = contentDialogForm.getApplicationComponent(CmsService.class);
536 cmsService.storeNode(contentDialogForm.contentType,
537 contentDialogForm.getNode().getParent(),
538 inputProperties,
539 contentDialogForm.isAddNew);
540
541 PublicationService publicationService = contentDialogForm.getApplicationComponent(PublicationService.class);
542 PublicationPlugin publicationPlugin = publicationService.getPublicationPlugins()
543 .get(publicationService.getNodeLifecycleName(webContentNode));
544 HashMap<String, String> context = new HashMap<String, String>();
545 if(webContentNode != null) {
546 context.put("Publication.context.currentVersion", webContentNode.getName());
547 }
548 publicationPlugin.changeState(webContentNode, PublicationDefaultStates.PUBLISHED, context);
549
550 if (Util.getUIPortalApplication().getModeState() == UIPortalApplication.NORMAL_MODE) {
551 ((PortletRequestContext)event.getRequestContext()).setApplicationMode(PortletMode.VIEW);
552 }
553 Utils.closePopupWindow(contentDialogForm, CONTENT_DIALOG_FORM_POPUP_WINDOW);
554
555 } catch(LockException le) {
556 Object[] args = {contentDialogForm.getNode().getPath()};
557 Utils.createPopupMessage(contentDialogForm,
558 "UIContentDialogForm.msg.node-locked",
559 args,
560 ApplicationMessage.WARNING);
561 } catch (AccessControlException ace) {
562 if (LOG.isWarnEnabled()) {
563 LOG.warn(ace.getMessage());
564 }
565 } catch (AccessDeniedException ade) {
566 Utils.createPopupMessage(contentDialogForm,
567 "UIDocumentInfo.msg.access-denied-exception",
568 null,
569 ApplicationMessage.WARNING);
570 } catch (VersionException ve) {
571 Utils.createPopupMessage(contentDialogForm,
572 "UIDocumentForm.msg.in-versioning",
573 null,
574 ApplicationMessage.WARNING);
575 } catch (ItemNotFoundException item) {
576 Utils.createPopupMessage(contentDialogForm,
577 "UIDocumentForm.msg.item-not-found",
578 null,
579 ApplicationMessage.WARNING);
580 } catch (RepositoryException repo) {
581 String key = "UIDocumentForm.msg.repository-exception";
582 if (ItemExistsException.class.isInstance(repo))
583 key = "UIDocumentForm.msg.not-allowed-same-name-sibling";
584 Utils.createPopupMessage(contentDialogForm, key, null, ApplicationMessage.WARNING);
585 } catch (NumberFormatException nfe) {
586 Utils.createPopupMessage(contentDialogForm,
587 "UIDocumentForm.msg.numberformat-exception",
588 null,
589 ApplicationMessage.WARNING);
590 } catch (Exception e) {
591 Utils.createPopupMessage(contentDialogForm,
592 "UIDocumentForm.msg.cannot-save",
593 null,
594 ApplicationMessage.WARNING);
595 }
596 }
597 }
598
599
600
601
602
603
604
605
606
607 static public class AddActionListener extends EventListener<UIContentDialogForm> {
608
609
610
611
612
613
614
615 public void execute(Event<UIContentDialogForm> event) throws Exception {
616 UIContentDialogForm contentDialogForm = event.getSource();
617 String clickedField = event.getRequestContext().getRequestParameter(OBJECTID);
618 if (contentDialogForm.isReference) {
619 UIApplication uiApp = contentDialogForm.getAncestorOfType(UIApplication.class);
620 try {
621 UIFormMultiValueInputSet uiSet = contentDialogForm.getChildById(FIELD_TAXONOMY);
622 if ((uiSet != null) && (uiSet.getName() != null)
623 && uiSet.getName().equals(FIELD_TAXONOMY)) {
624 if ((clickedField != null) && (clickedField.equals(FIELD_TAXONOMY))) {
625 NodeHierarchyCreator nodeHierarchyCreator = contentDialogForm.getApplicationComponent(NodeHierarchyCreator.class);
626 String repository = contentDialogForm.repositoryName;
627 DMSConfiguration dmsConfiguration = contentDialogForm.getApplicationComponent(DMSConfiguration.class);
628 DMSRepositoryConfiguration repositoryConfiguration = dmsConfiguration.getConfig();
629 String workspaceName = repositoryConfiguration.getSystemWorkspace();
630 UIOneTaxonomySelector uiOneTaxonomySelector = contentDialogForm.createUIComponent(UIOneTaxonomySelector.class,
631 null,
632 null);
633 if (uiSet.getValue().size() == 0)
634 uiSet.setValue(new ArrayList<Value>());
635 String rootTreePath = nodeHierarchyCreator.getJcrPath(BasePath.TAXONOMIES_TREE_STORAGE_PATH);
636 RepositoryService repositoryService = (RepositoryService) contentDialogForm.
637 getApplicationComponent(RepositoryService.class);
638 ManageableRepository manageableRepository = repositoryService.getCurrentRepository();
639 Session session = WCMCoreUtils.getUserSessionProvider()
640 .getSession(workspaceName, manageableRepository);
641 Node rootTree = (Node) session.getItem(rootTreePath);
642 NodeIterator childrenIterator = rootTree.getNodes();
643 while (childrenIterator.hasNext()) {
644 Node childNode = childrenIterator.nextNode();
645 rootTreePath = childNode.getPath();
646 break;
647 }
648 uiOneTaxonomySelector.setRootNodeLocation(repository, workspaceName, rootTreePath);
649 uiOneTaxonomySelector.setExceptedNodeTypesInPathPanel(new String[] { "exo:symlink" });
650 uiOneTaxonomySelector.init(WCMCoreUtils.getUserSessionProvider());
651 String param = "returnField=" + FIELD_TAXONOMY;
652 uiOneTaxonomySelector.setSourceComponent(contentDialogForm, new String[] { param });
653 Utils.createPopupWindow(contentDialogForm,
654 uiOneTaxonomySelector,
655 TAXONOMY_CONTENT_POPUP_WINDOW,
656 700);
657 }
658 }
659 } catch (AccessDeniedException accessDeniedException) {
660 uiApp.addMessage(new ApplicationMessage("UIContentDialogForm.msg.access-denied",
661 null,
662 ApplicationMessage.WARNING));
663 return;
664 } catch (Exception e) {
665 uiApp.addMessage(new ApplicationMessage("UIContentDialogForm.msg.exception",
666 null,
667 ApplicationMessage.WARNING));
668 return;
669 }
670 } else {
671 event.getRequestContext().addUIComponentToUpdateByAjax(contentDialogForm);
672 }
673 }
674 }
675
676
677
678
679 public void activate() {
680 }
681
682
683
684
685 public void deActivate() {
686 }
687
688
689
690
691 @SuppressWarnings("unchecked")
692 public void doSelect(String selectField, Object value) throws Exception {
693 isUpdateSelect = true;
694 UIFormInput formInput = getUIInput(selectField);
695 if(formInput instanceof UIFormInputBase) {
696 ((UIFormInputBase)formInput).setValue(value.toString());
697 }else if(formInput instanceof UIFormMultiValueInputSet) {
698 UIFormMultiValueInputSet inputSet = (UIFormMultiValueInputSet) formInput;
699 String valueTaxonomy = String.valueOf(value).trim();
700 List taxonomylist = inputSet.getValue();
701 if (!taxonomylist.contains(valueTaxonomy)) {
702 listTaxonomy.add(valueTaxonomy);
703 listTaxonomyName.add(valueTaxonomy);
704 taxonomylist.add(valueTaxonomy);
705 }
706 inputSet.setValue(taxonomylist);
707 }
708 }
709
710
711
712
713
714
715
716
717
718
719 static public class RemoveReferenceActionListener extends EventListener<UIContentDialogForm> {
720
721
722
723
724 public void execute(Event<UIContentDialogForm> event) throws Exception {
725 UIContentDialogForm contentDialogForm = event.getSource();
726 contentDialogForm.isRemovePreference = true;
727 String fieldName = event.getRequestContext().getRequestParameter(OBJECTID);
728 contentDialogForm.getUIStringInput(fieldName).setValue(null);
729 event.getRequestContext().addUIComponentToUpdateByAjax(contentDialogForm);
730 }
731 }
732 }