Which is the better way to access pageflowscope variable in ADF - oracle-adf

As we know there are multiple ways to access the page flow scope variable but which one is the right one?
ex RequestContext.getCurrentInstance().getPageFlowScope();
AdfContext.getCurrent.getPageFlowScope();
FacesContext?
I am also curios to know what the differences are between all these Contexts.

Both methods RequestContext.getPageFlowScope and AdfContext.getPageFlowScope return the same thing. You can use both.

Related

How to keep square brackets in single array using Logic Apps?

I am parsing an XML document to JSON, and eventhough I have the type array declared in the json schema, if there is just one element in the array it gets transformed into an objet like this.
"ListOfCodes":{"Codes":{{"Code":"111"}}}
but I need this:
"ListOfCodes":{"Codes":[{"Code":"111"}]}
I have several arrays in the document and I only get the sqare brackets when there is a multiple array.
and adding the properties manually is not an option.
Anyone know what can i modify to fix this in the logic app?
Unfortunately, there isn't a good solution for us to implement this requirement in logic app. Here is another post which is similar to your problem. To implement the requirement, we can just:
1. Use the "Compose" action to generate the object by hand (manually put all the properties and arrays where they need, potentially using the #array() action.
2. Call an Azure Function or some external code that can more specifically craft a valid JSON.
I also try to test it in some other way, such as use json:Array="true" and use <?xml-multiple?> but they all fail in logic app. So I think the only above two solutions(mentioned in that post) can be used. Neither approach is good, though.

Cohesive block of code

I'm currently reading about modules in angular 2. In Angular documentation there is statement:
"A typical module is a cohesive block of code dedicated to a single purpose."
I want to figure out what they mean by a cohesive block of code?
Can someone explain it simply?
I googled, but I didn't found any good explanation which is simple.
Thanks!
I think in simple terms you can put it like this - In angular2 the application view is segregated into components. The components have their view and controller. Hence, it enforces better reuse.
I guess this means something like explained in Single responsibility principle
A class should do one thing and do it well.
A module it similar, just with a bit wider scope.
Cohesive means closely related or belonging together.
The concept of Cohesion: means the things that are related should always be part of one unit. They should go together this is called Cohesion.

Angular lookup value/display value

I have some data on a model that comes in the form of a code such as "US60" and "US70".
I need to take that value and show a display value such as "US 7day/60hour" and "US 8day/70hour". I'm not sure if there is any best practices way to do this in Angular, and I'm not having much luck googling it.
What I would do is have a service that I pass in type and value, and it would return a display value, but as with many things in Angular, since this is my first Angular project, I don't know if it's a good way to do it or not.
I'm just needing to use the display value in html such as {{settings.cycle}} I am already able to access the variable, but I want to show the display value, not the actual value.
If I am getting the gist of your question correctly, you have the value available but want to alter how it is displayed on screen right?
There are two main approaches to do this in Angular, using a directive or a filter.
A filter is basically like a pipe in Unix. You can alter a value before it is being displayed. For example:
{ username | uppercase } will transform the username into an all-caps username. Naturally, you can define your own filters for your use case. Filters are mostly used to transform single values. So for your case, a filter sounds best.
A directive is commonly used to create entire components on a page. For example: <user-profile-card></user-profile-card> would be transformed, using the directive, into the appropriate html/css/logic. So these are used often for larger transformations which involve logic, like server requests. Still these directives could also be used for very small components.
So for your case, although what you are actually want to do is not completely clear to me honestly, a filter seems to be your best shot ;)

Watch pattern to combine multiple variables into one watch

sometimes when I implement watch pattern in my directives in angular, I need to evaluate multiple values at once but want the watch pattern to trigger only once. Lately I found the watchGroup that I was hoping it would do exactly the mentioned behavior above but unfortunately it doesn't so I came up with this idea of hashing my values to in a watch using a function as a first parameter. So I was wondering is this a good idea? Is there pitfall in this pattern?
Assuming that foo and bar are values between 0-99.
$scope.$watch(function(){ return foo*100+bar}, function(){//This only triggers once!});
Thanks for the inputs.
Mark
have your tried $watchCollection(obj, listener)? this API can help you watch an array of values.
check out this

In an AngularJS expression is there a way to compare a scope value to a value in another library?

I'm creating a directive around a third party library, to go in a form, where the option chosen in a select drop-down will bring up a different set of form elements.
In the parent element of each subset of form elements I'm trying to use an expression similar to this: ng-if="myScopeObj.val === ThirdParty.CONSTANT_VAL". I came to realize it's not working because the "ThirdParty" library isn't on the scope.
Should I just assign the library to a variable on the scope, or is there some pattern that can address this? It seems like creating isThis() or isThat() functions for every constant in the library wouldn't be a great solution.
Should I create a service to wrap the third party library and then inject it into the directive? Though I'd still need to put the injected service on the scope. Would that be overkill for a library that doesn't access remote APIs? I don't think it'd need to be mocked for testing, anyway.
You're correct that you do need to get the value on the $scope somehow in order for it to be usable. And you're correct that one of the primary benefits of wrapping in a service is that you can mock the library. Another benefit of wrapping in a service is self-documentation. As someone else (or yourself at a later time) looking at your code, I could be confused as to where ThirdParty is coming from. Working in Angular, the assumption is that all dependencies are injected, and breaking convention comes at a cognitive cost. Having a service also can make it easier to swap out the underlying library later for a different implementation. Anyway, your simplest fix is:
$scope.ThirdParty = ThirdParty;

Resources