NdsBeisUi/src/main/java/com/northgateps/nds/beis/ui/field/ExemptionTypeTextComponent.java
/** 
     * Get the ExemptionTypeText reference data from the ESB.
     * Calls namedEnumerationList.getBeanWrapper() to update the model and cache.
     */
Get the ExemptionTypeText reference data from the ESB.
Calls namedEnumerationList.getBeanWrapper() to update the model and cache.
Get the ExemptionTypeText reference data from the ESB . Calls namedEnumerationList . getBeanWrapper () to update the model and cache .
@Override
    public void prepare(AbstractNdsMvcModel model, ControllerState<?> controllerState, String targetSlice) {
        for (NamedEnumerationList namedEnumerationList : namedEnumerationLists.values()) {
            GetPrsExemptionRefDataNdsRequest submitRequest = new GetPrsExemptionRefDataNdsRequest();
            final UiServiceClient uiSvcClient = controllerState.getController().getUiSvcClientFactory().getInstance(
                    GetPrsExemptionRefDataNdsResponse.class);
            uiSvcClient.setTargetSlice("before-prepare-view");
            if (!controllerState.isSyncController()) {
                uiSvcClient.post(serviceEndPoint, submitRequest);
            } else {
                uiSvcClient.postSync(serviceEndPoint, submitRequest);
            }
            uiSvcClient.setResponseConsumer(new NdsResponseConsumer() {
                @Override
                public boolean consume(NdsResponse response) {
                    if (!(response instanceof GetPrsExemptionRefDataNdsResponse)) {
                        return false;
                    }
                    GetPrsExemptionRefDataNdsResponse fetchResponse = (GetPrsExemptionRefDataNdsResponse) response;
                    if (fetchResponse.getNdsMessages() != null) {
                        model.setPostSubmitMessage(new ViewMessage("Error_ESB_withCausedBy", fetchResponse.getNdsMessages()));
                    } else {
                        try {
                            List<ExemptionTypeDetails> returnedValues = fetchResponse.getExemptionTypeTextList();
                            ArrayList<ExemptionTypeText> values = new ArrayList<ExemptionTypeText>();
                            for (int i = 0; i < returnedValues.size(); i++) {
                                values.add(convertExemptionTypeText(returnedValues.get(i)));
                            }
                            namedEnumerationList.getBeanWrapper().setPropertyValue(namedEnumerationList.getName(), values);
                        } catch (Exception e) {
                            logger.error("Could not set reference data set", e);
                        }
                    }
                    return true;
                }
            });
            controllerState.registerUiServiceClient(uiSvcClient);
        }
    }
@ Override public void prepare ( AbstractNdsMvcModel model , ControllerState < ? > controllerState , String targetSlice ) { for ( NamedEnumerationList namedEnumerationList : namedEnumerationLists . values ( ) ) { GetPrsExemptionRefDataNdsRequest submitRequest = new GetPrsExemptionRefDataNdsRequest ( ) ; final UiServiceClient uiSvcClient = controllerState . getController ( ) . getUiSvcClientFactory ( ) . getInstance ( GetPrsExemptionRefDataNdsResponse . class ) ; uiSvcClient . setTargetSlice ( "before-prepare-view" ) ; if ( ! controllerState . isSyncController ( ) ) { uiSvcClient . post ( serviceEndPoint , submitRequest ) ; } else { uiSvcClient . postSync ( serviceEndPoint , submitRequest ) ; } uiSvcClient . setResponseConsumer ( new NdsResponseConsumer ( ) { @ Override public boolean consume ( NdsResponse response ) { if ( ! ( response instanceof GetPrsExemptionRefDataNdsResponse ) ) { return false ; } GetPrsExemptionRefDataNdsResponse fetchResponse = ( GetPrsExemptionRefDataNdsResponse ) response ; if ( fetchResponse . getNdsMessages ( ) != null ) { model . setPostSubmitMessage ( new ViewMessage ( "Error_ESB_withCausedBy" , fetchResponse . getNdsMessages ( ) ) ) ; } else { try { List < ExemptionTypeDetails > returnedValues = fetchResponse . getExemptionTypeTextList ( ) ; ArrayList < ExemptionTypeText > values = new ArrayList < ExemptionTypeText > ( ) ; for ( int i = 0 ; i < returnedValues . size ( ) ; i ++ ) { values . add ( convertExemptionTypeText ( returnedValues . get ( i ) ) ) ; } namedEnumerationList . getBeanWrapper ( ) . setPropertyValue ( namedEnumerationList . getName ( ) , values ) ; } catch ( Exception e ) { logger . error ( "Could not set reference data set" , e ) ; } } return true ; } } ) ; controllerState . registerUiServiceClient ( uiSvcClient ) ; } }
Get the ExemptionTypeText reference data from the ESB.
Get the ExemptionTypeText reference data from the ESB .
// create and post the request // load the list before calling the onAfterResolvedView handlers // convert the returned list to the UI list // update the model and cache, effectively calls NamedEnumerationListProxy.setCvList()