cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Translate the entire conversation x

Unable to read the list of selected objects from folder for validateMultiselectedAction

MainuddinShaik
6-Contributor

Unable to read the list of selected objects from folder for validateMultiselectedAction

Version: Windchill 12.0

 

Use Case: Validating all Selected objects with few conditions during validateSelectedMultiSelectAction


Description:

I am selecting multiple objects(Documents/Parts ) from the folder to perform to trigger an action which performs setState/Workflow initiation.
Here  reading the list of objects from command bean/validation criteria returning the null.

When I am selecting one object it is returning the object and validateSelectedAction is executed with out any issues.

I tried multiple ways to get the selected objects by changing the window type= normal popup new no content and etc...

I also used different apis to read the objects but none is working.

 

All these api's were returning the selected objects like 2 months back now all of a sudden it all stopped returning the objects.

Used below apis to get the selected objects from the folder  .

WTCollection targetObjects = new WTArrayList(criteria.getTargetObjects());
final List<NmOid> selectedListOidForPopup = nmCommandBean.getSelectedOidForPopup();
commandBean.getSelectedOidForPopup()

 

Same happened with the servletRequest where it was not returning all the selected objects as a work around I used the jsp as an intermidate point to read the selected objects and then redirected to customservlet storing these objects in an attribute. 

 

@HelesicPetr  @avillanueva 

9 REPLIES 9

Hi @MainuddinShaik 

Try all following methods. I know you've already used one but try it

One of them should return all selected objects. 

nmCommand.getNmOidSelected();
nmCommand.getNmOidSelectedInOpener();
nmCommand.getSelectedOidForPopup();
nmCommand.getSelectedInOpener();
nmCommand.getSelectedFromOpenedWizard();

PetrH

From the logs I can tell that validateSelected and validateSelectedMultiSelectAction are not at all executed.

It returned an empty list from validate selected.

Logers :
For Single objects is selected:
actionName=setToXXXXXXXXX, Performing full pre validation...
Reading objects from nmCommandBean...
getNmOidSelected:[]
getNmOidSelectedInOpener:[]
getSelectedOidForPopup:[]
getSelectedInOpener:[]
getSelectedFromOpenedWizard:[]
objects=[wt.doc.WTDocument:413320506], Read objects from nmCommandBean.
Reading objects from nmCommandBean...
getNmOidSelected:[]
getNmOidSelectedInOpener:[]
getSelectedOidForPopup:[]
getSelectedInOpener:[]
getSelectedFromOpenedWizard:[]
objects=[wt.doc.WTDocument:413320506], Read objects from nmCommandBean.
  actionName=setToXXXXXXXXX, status=PERMITTED, Performed full pre validation.
When multiple objects are selected :
  actionName=setToXXXXXXXXX, Performing full pre validation...
Reading objects from nmCommandBean...
getNmOidSelected:[]
getNmOidSelectedInOpener:[]
getSelectedOidForPopup:[]
getSelectedInOpener:[]
getSelectedFromOpenedWizard:[]
objects=[], Read objects from nmCommandBean.
Reading objects from nmCommandBean...
getNmOidSelected:[]
getNmOidSelectedInOpener:[]
getSelectedOidForPopup:[]
getSelectedInOpener:[]
getSelectedFromOpenedWizard:[]
objects=[], Read objects from nmCommandBean.
actionName=setToXXXXXXXXX, status=HIDDEN, Performed full pre validation.

 

 

 

 

Below is the code I'm using. Added all the logs mentioned above but this method itself not being triggered during the validation. After enabling JCADebug this validator is hiding the action.

 

This validator class extends DefaultUIComponentValidator

 

 

 

 

 

 @Override
    public UIValidationResultSet validateSelectedMultiSelectAction(
        final UIValidationKey validationKey, final UIValidationCriteria criteria,
        final Locale locale) throws WTException {
        LOGGER.info(
            "actionName={}, status={}, Executing validateSelectedMultiSelectAction validation.",
            validationKey.getComponentID(), UIValidationStatus.PERMITTED.toString());
        final UIValidationResultSet uiValidationResultSet = UIValidationResultSet.newInstance();
        final NmCommandBean commandBean = NmCommandBean.getNmCommandBean(criteria.getFormData());
        LOGGER.info("getNmOidSelected::" + commandBean.getNmOidSelected());
        LOGGER.info("getNmOidSelectedInOpener::" + commandBean.getNmOidSelectedInOpener());
        LOGGER.info("getSelectedOidForPopup::" + commandBean.getSelectedOidForPopup());
        LOGGER.info("getSelectedInOpener::" + commandBean.getSelectedInOpener());
        LOGGER.info("getSelectedFromOpenedWizard::" + commandBean.getSelectedFromOpenedWizard());
        LOGGER.info("with popup criteria popup::" + criteria.getSelectedOidForPopup().size());
        final String actionName = validationKey.getComponentID();
        final List<String> errorMessages = validateSelectedAction(commandBean, actionName);
        if (!errorMessages.isEmpty()) {
            errorMessages.add(0, WTMessage.getLocalizedMessage(RESOURCE, HEADER_ERROR_MSG));
            final UIValidationFeedbackMsg feedbackMsg = UIValidationFeedbackMsg.newInstance(
                String.join(SEPARATOR, errorMessages), FeedbackType.FAILURE);
            uiValidationResultSet.addResult(UIValidationResult.newInstance(validationKey,
                UIValidationStatus.DENIED, feedbackMsg));
            LOGGER.info(
                "actionName={}, status={}, Executed validateSelectedMultiSelectAction validation.",
                validationKey.getComponentID(), UIValidationStatus.PERMITTED.toString());
        } else {
            UIValidationResult uiValidationResult = UIValidationResult.newInstance(validationKey,
                UIValidationStatus.PERMITTED);
            uiValidationResultSet.addResult(uiValidationResult);
            LOGGER.info(
                "actionName={}, status={}, Executed validateSelectedMultiSelectAction validation.",
                validationKey.getComponentID(), UIValidationStatus.PERMITTED.toString());
        }
        return uiValidationResultSet;
    }

 

 

 

 

 

Hi @MainuddinShaik 

Find the method that is triggered. 

I guess that your definition of the validator is not well defined. 

 

How do you call the validator ? where ? where is definition that the validator should be used?

 

PetrH

This is my custom action.

 

<objecttype name="nameXXX" resourceBundle=" package.CustomActionResource">
<action multiselect="true" name="setToXXXXXXXXX" selectRequired="true">
<command class="package.className" method="execute" />
</action>
</objecttype>

 

 

this action is add under docs row actions toolbar and  folderbrowser_toolbar_actions

 

this is my validator added in the custom service.properties also visible under custom action report when enabling the jcaDebug:

 

wt.services/svc/default/com.ptc.core.ui.validation.UIComponentValidator/setToXXXXXXXXX/null/0=package.ValidatorClass/duplicate
public class className extends DefaultUIComponentValidator {

    @Override
    public UIValidationResultSet performFullPreValidation(final UIValidationKey validationKey,
        final UIValidationCriteria criteria, final Locale locale) throws WTException {
        LOGGER.info("actionName={}, Performing full pre validation...",
            validationKey.getComponentID());
        // code here............
        return UIValidationResultSet.newInstance(
            UIValidationResult.newInstance(validationKey, UIValidationStatus.HIDDEN));
    }

    @Override
    public UIValidationResult validateSelectedAction(final UIValidationKey validationKey,
        final UIValidationCriteria criteria, final Locale locale) throws WTException {
        // code here............
        return uiValidationResult;
    }

    @Override
    public UIValidationResultSet validateSelectedMultiSelectAction(
        final UIValidationKey validationKey, final UIValidationCriteria criteria,
        final Locale locale) throws WTException {
       // code here............
        return uiValidationResultSet;
    }
 
}

 

 

 

 

Hi @MainuddinShaik 

 I usually define the validator as a SimpleValidationFilter in the service

com.ptc.core.ui.validation.SimpleValidationFilter

 

and also I usually set the validator in the action.xml definition  

<objecttype name="nameXXX" resourceBundle=" package.CustomActionResource">
<action multiselect="true" name="setToXXXXXXXXX" selectRequired="true">
<command class="package.className" method="execute" />
<includeFilter name="setToXXXXXXXXX"/>
</action>
</objecttype>

PetrH

What you replied is a simple filter implementation.

 

My implementation is to display a pop up upon selecting multiple objects and performing an action. This popup should show all the list of validations messages to user. 

that requires to override validateSelectedAction and validateSelectedMultiSelectAction. These methods are not called upon triggering the action.

 

I think there is a bug in windchill.

 

Hi @MainuddinShaik 

I just show example how to implement filter. 

Yes it is different. but it could help to identify what you are doing wrong. 

 

I don't think there is a bug, you just didn't overwrite the method. what you are talking about. 

 

btw, based on your log output, the method is run in your situation, but there are not any inputs. 

 

PetrH 

Hi @MainuddinShaik 

btw you wrote, that it worked a month agou

 

so what has been changed since then?

 

PetrH 

if I write a validator in a single class including all the 3 validations it is working now.

if I implement a validator class extending the base class which extends DefaultUIComponentValidatorthen itis not working.

What is working with this implementation:

(1) when I right click on the object action is visible.

(2) From object info page action is visible

(3)If I select 1 or more objects and select folder actions this action is hidden. (folderbrowser_toolbar_actions)

 

Eg:

public abstract class baseClass extends DefaultUIComponentValidator {

    @Override
    public UIValidationResultSet performFullPreValidation(final UIValidationKey validationKey,
        final UIValidationCriteria criteria, final Locale locale) throws WTException {
        LOGGER.info("actionName={}, Performing full pre validation...",
            validationKey.getComponentID());
        // code here............
          abstract method1();
        return UIValidationResultSet.newInstance(
            UIValidationResult.newInstance(validationKey, UIValidationStatus.HIDDEN));
    }

    @Override
    public UIValidationResult validateSelectedAction(final UIValidationKey validationKey,
        final UIValidationCriteria criteria, final Locale locale) throws WTException {
        // code here............
          abstract method2();
        return uiValidationResult;
    }

    @Override
    public UIValidationResultSet validateSelectedMultiSelectAction(
        final UIValidationKey validationKey, final UIValidationCriteria criteria,
        final Locale locale) throws WTException {
       // code here............
         abstract method2();
        return uiValidationResultSet;
    }
     abstract protected boolean isObjectSelected(final NmCommandBean nmCommandBean)
        throws WTException;

    abstract protected boolean method1(final NmCommandBean nmCommandBean
       ) throws WTException;

    abstract protected List<String> method2(final NmCommandBean nmCommandBean ) throws WTException;
}

public class mainValidator extends  baseClass  {

  @Override
    protected boolean method1(final NmCommandBean nmCommandBean){
return;
     }
 
 @Override
    protected boolean method2(final NmCommandBean nmCommandBean){
return ;
      }


}

 

Announcements
Top Tags