Pages

Wednesday, November 13, 2013

Fetch User's Email Address in UCM Custom Component when using AD as LDAP

I was working on a custom component in UCM and AD was used as LDAP . There was a need to send emails to multiple users subscribed to a custom query. I used the below code to fetch the user's email address in UCM component -

    private String getIndividualUserEmail(String userId) {
        String emailAddress = "";

        try {
            JpsContextFactory ctxf = JpsContextFactory.getContextFactory();
            JpsContext ctx = ctxf.getContext();
            IdentityStoreService storeService =
                ctx.getServiceInstance(IdentityStoreService.class);
            IdentityStore idStore = storeService.getIdmStore();
            SimpleSearchFilter simpleFilter =
                idStore.getSimpleSearchFilter(UserProfile.USER_NAME,
                                              SimpleSearchFilter.TYPE_EQUAL,
                                              userId);
            SearchParameters params =
                new SearchParameters(simpleFilter, SearchParameters.SEARCH_USERS_ONLY);
            SearchResponse sr = idStore.searchProfiles(params);
            System.out.println(sr.getResultCount());
            while (sr.hasNext()) {
                Identity id = sr.next();
                UserProfile profile = (UserProfile)id;
                emailAddress = profile.getBusinessEmail();
                System.out.println("Email :- " + profile.getBusinessEmail());

            }
        } catch (JpsException e) {
            System.out.println("getIndividualUserEmail : JpsException Occured ");
        } catch (IMException e) {
            System.out.println("getIndividualUserEmail : IMException Occured ");
        }
        return emailAddress;
    }

Enjoy

InputListOfValues - Control custom popup launch

I went through the code of ADF Faces Demo-inputListOfValues -
1. It has customPopup in searchFacet.
2. A custom PopuplaunchListener .

If you write someValue in inputField and tab out, customPopupLaunch Listener gets called. It checks if the entered value is complete then popup Launch is cancelled using below code.

event.setLaunchPopup(false); 

Small addition to above requirement : You write the complete value and click lov icon. Popup gets launched... But what if you want to block the popup launch on click of lov icon when complete value is entered.

Thanks to Oracle Forum.. where I got the answer.
https://forums.oracle.com/thread/2598020

All you need to do is short-circuit the JSF Life cycle.

FacesContext.getCurrentInstance().responseComplete();

Enjoy. 

Friday, September 27, 2013

Dynamic Region Refresh Issue


In general when we use dynamic region, we have multiple buttons/links which change the taskflowId and partial trigger on dynamicRegion . This refreshes the taskflow loaded in dynamic Region. Recently I encountered a usecase where dynamic region is not refreshing or reset is not happening.




InputText fields has required="true" and CommandButtons in the above page have immediate="true" so that it is able to navigate to another taskflow. Now as we go ahead with implementation of changing the taskflowId and partialTrigger on dynamicRegion, the value in the inputText field is retained, even though taskflow is reloaded .

Finally I was able to resolve this reset issue with help on Jdeveloper And ADF Forum..https://forums.oracle.com/thread/2585988 . Thanks to Frank.

Solution is to switch the taskflow using below code :
oracle.adf.view.rich.util.ResetUtils.reset(regionId_in_here);

Download the sample from here