WSO2 Identity Server 5.0.0 boolean claims - wso2

I am trying to add custom boolean claims to my user profiles. I added claim in the http://wso2.org/oidc/claim dialect and then added the necessary mapping in the http://wso2.org/claims and made the claim supported by default. I want to store boolean value in that custom claim (true/false). Once I open some identity I see a blank value for that claim. If I store the value "true" and save the profile, I receive a checkbox with tick. If I then go and update some other field of the same identity and click save, the boolean value is preserved and I am still seeing the checkbox with the tick (which represents the "true" value). Then I decided to uncheck the value for my custom boolean claim in order to store the "false" value for the claim. But once I clicked "save" button, I was no longer seeing the empty checkbox (which I expect to represent the "false" value). Instead I am seeing a blank field which expects value. At this moment if I try to call the user info endpoint, I am not retrieving the mentioned custom claim. In order to receive a false value for it, I need to go to the mentioned identity, explicitly type "false" and save the identity. After that I receive the "false" value for that claim. Then if for some reason someone goes after me and update another part of the identity, the "false" value for my custom claim is lost and I fall in the previous situation and I am not able to get the value for the custom claim, because it is not defined.
I am using "Account locked" claim and I am not able to observe such behavior with this claim. I suppose because it is a sort of special one, because it is used by the identity management.
Is there a way to workaround this situation? For the moment I made the claim "required" and you are not able to save the identity with an empty value for that claim (through the IS Admin Console).
Is this expected behavior when it comes to boolean claims in the WSO2 IS 5.0.0?

This is the expected behavior. Claims can have any value (numeric, boolean, text etc.) and therefore Identity Server cannot identify the data type of the claim. However booleans are treated little bit different. Initially when you add the claim, it will be displayed as a text box as IS cannot decide the data type. Once you save the user profile adding either 'true' or 'false' as the value for the text box (for the very first time), then internally IS will identify this claim to be a boolean. From then onwards it will be displayed as a check box in the UI.

Related

Why doesn't Web Forms for Marketers correctly populate the selected DropList value in my custom save action?

Inside my custom save action, I iterate through the form fields (the AdaptedControlResult objects). Any form field which is a DropList (from any source -- manually entered values, or an item lookup) is returning a string value of System.Collections.Generic.List`1[System.String]
Now, it's important to know, it's not returning an actual List. It's returning a literal string with that value.
So, this call:
fields.GetEntryByName("MyFieldName").Value
Is returning the string: System.Collections.Generic.List`1[System.String]. Not the value of the dropdown. A string saying that's it's a List<string>.
I have confirmed the HTML of the form is rendering correctly. I have manually checked the inbound HttpContext.Current.Request.Form values as well...
HttpContext.Current.Request.Form["BGWnjkQqrE6w6sr31IgzrQ.Sections[5].Fields[0].Value"]
That is the correctly-selected value of the drop down (a Sitecore ID).
So, the data is getting output to the form correctly, and the inbound Request.Form data is also correct. Somewhere, Sitecore is deciding not to populate the selected value into the AdaptedControlResult object.
What's additionally odd is that for DropList field types, the selected value does appear in the Parameters property (inexplicably). I would just detect this and use it, but it's not consistent -- for instance, for textbox field types, the word "multiline" appears there.
All other field types work fine -- I have several text entry fields, and some radio button lists. It's just DropList fields.
What is the trick to getting this?
This is a known bug in Sitecore when using the WFFM module in MVC. You can find more details in this Knowledge Base Article - Incorrect data is saved for list fields in WFFM MVC.
The fix is listed on the kb article and depends on the exact version of Sitecore you are using. Sorry to provided a link only answer but there are multiple steps reqiured for the fix and the download for the fix is attached in the article.

How to do Odoo Leave Type Filter(user has only display 2 leave type admin need to display all)?

user(employee) has to display only 2 leave type and admin(HR officer) has to display all leave type
You can easily achieve this by creating one field in 'hr.holidays.status' model like whether this leave is visible to manager or not.
By overwriting onchange of holiday_status_id and return domain as per logged in user by checking whether it is a manager or not.

Cannot get Read Only Condition to work on Oracle Apex page

Trying to add a read condition to my page. Nothing I am doing works. I would like to use the PL/SQL Expression condition type but cannot get it to evaluate properly. My app is a workflow application and I want the page to display in READ mode when the status is not DRAFT. So, naturally I try to code the Expression as:
:P2_PDD_STATUS_CD != 'DRAFT'
This results in the page being opened in edit mode no matter what the status value. What am I missing? I've verified the column name several times. As a matter of testing, I was not able to get the Expression 1 = Expression 2 condition type to work either.
Getting APEX Page Item Conditional Properties to Work as Designed:
The Quick Answer: Wherever you place the page item that influences the READ-ONLY state of the text field page/region item, the change in its value/state has to happen sequentially before the event that fetches and displays the conditionally read-only text field...
The best way to make sure the state you have changed "sticks" is to associate a page redirect with that field so that the rest of the page items and dependent properties has an opportunity to recognize that the read-only page indicator value has been altered (from DRAFT to non-DRAFT, etc.)
The Test Data Schema: Speech Writer's Block App
This example uses a single table. The text-document is an oversized VARCHAR2 typed field, though it really could be anything... even a LOB/CLOB typed value for larger capacity. The schema:
The PAGE Design and Layout
The example is designed in a single page. Two regions: The speech catalog (top) and the speech editor form (bottom) are processed in the following order:
Query the speech catalog for the report display (fetch)
If a SPEECH_ID value was designated at page-load (or reload) fetch all fields for the speech document record where the speech id = the page item containing the speech id value.
If a SPEECH_Id was recently chosen (after the page is rendered), then redirect the page to itself setting page item SPEECH ID = selected speech id #.
The FORM Region Design
This defines what the "edit" button does from the report output of possible speech selections. Notice that selecting this button value sets an automatic redirect to the same page, containing the revised STATUS-MODEvalue.
Rendering Sequence Design
The rendering of the page passes through each region and design block once. If a item value is upstream (i.e., processed before) from a defining item value (such as the STATUS: DRAFT, ARCHIVE, etc.)... or it can be changed after the page render is completed, a redirect action would help in this case.
The Conditional READ-ONLY Page ITEM Property
Output and Results
Normal Speech Edit (DRAFT) Mode
Archive Mode for READ ONLY Speech Text Access
Discussion of Alternative Designs
It is possible to do this with a workflow that spans multiple pages. It might even be easier that way. For example, the determining, incoming page item properties should be set at ANY time prior to when the previous page is redirected to it.
Additional Comments (aside)
Sorry in advance for the slightly abnoxious-sized watermark-credits text on my screen-captures. I'm set up with a new tool (Skitch) and it is nearly impossible to get a sense of scale when it's finally home within a Stack Overflow post...
Enjoy anyways: Onward!

Refreshing a new document so default displays in computed control

This problem has been bugging me for awhile and I can not seem to get around it. So I stripped it down to the most basic level.
1. created a new XPage and bound it to an exiting form
2. created a panel called 'displayPanel'
3. inside the panel create a comboBox and give it a few values and a default value of any valid value.
4. Set an onChange event that does a partial refresh of displayPanel
5. Add a computed field that simply displays the value of the comboBox.
6 added a button that does a partial refresh of displayPanel onClick.
Open the XPage and the computed field is blank, make a change and the computed field displays.
open the XPage again and click the refresh button and the computed field displays
Now this is a very simple example but what I need to do is actually more complex but the value of the comboBox (Does not need to be a comboBox) is not available until a refresh is performed. This is only an issue on a new document when it first gets it's defaults.
I have added this:
view.postScript("XSP.partialRefreshGet('#{id:displayPanel}')")
to every one of the page events but it does not appear to do an actual page refresh like clicking the button or making a change.
I'm at a loss as to how to make this work. If I could get this simple example to work the rest of what I need is easy.
Thanks
Fredrik is on the right track -- you should set the value manually during an event -- but I would add two caveats:
Call setValue instead of replaceItemValue (e.g. document1.setValue("myComboBox", "Default Value");). The comparative advantages might not be applicable in this specific case, but you should be in the habit of always calling setValue instead of replaceItemValue (and getValue instead of getItemValue) so that, when you've encountered a scenario where it makes a real difference, you just get that benefit for free... the rest of the time, the methods are equivalent, so you might as well just use the one that requires less typing. :)
You'll probably need to do this in afterPageLoad: the data source may not be ready yet during beforePageLoad; depending on why you're referencing the default value elsewhere in your page, beforeRenderResponse might be too late; and afterRenderResponse would definitely be too late...
...which leads me to why the defaultValue attribute does not behave the way we might expect it to, especially for those of us with experience developing Notes client apps.
The XPages engine splits the processing of every HTTP request into several "phases". Depending on the type of request (initial page load, partial refresh event, etc.) and other factors, the lifecycle will consist of as many as 6 phases and as few as 2.
This tutorial page provides an excellent description of these phases, but in the context of this question, the following are specifically of interest:
Apply Request Values
When an event runs against a page that has already been loaded (e.g. a user clicks a button, or selects a value from a combobox that has an onChange event, etc.), the HTTP request sent to the server to trigger the event includes POST data that represents the value of all editable components. This phase temporarily stores these values in the submittedValue property of any affected components, but the data source doesn't "know" what the new values are yet.
Process Validations
This phase runs any applicable validators and, if any fail, skips straight to the last phase (which means it never runs the code of the event that was triggered).
Update Model Values
If no validations fail (or none are defined), this phase takes the submitted values and actually stores them in the corresponding data source. Until this point, the data source is completely unaware that there has been any user interaction. This is intended to avoid prematurely polluting any back end data with user input that might not even be valid. Remember, not every data source is a "document"; it might be relational data that is changed via an UPDATE the instant setValue is called... which is basically what this phase does: it takes the submittedValue and calls setValue on the corresponding data source (and then sets submittedValue to null). This separation allows components to simply be visual representations of the state of the back end data -- visual representations that the user interacts with; our code should always be interacting directly with the back end data via the abstraction layer of a data source.
Render Response
Once all of the other phases have run (or been skipped), this phase sends a response to the consumer. In other words, it sends HTML (or JSON, or XML, or PDF, etc.) back to the browser. But the most salient point in the context of this question is that the prior phases are always skipped on initial page load. When the user first accesses a page, they haven't had a chance to enter any data yet, so there are no request values to be applied. Since no data has been posted, there's nothing to validate. And -- most pertinent of all -- there's nothing to be pushed to the data model. So a representation of the component tree (or a subset of it, in the case of a partial refresh event) always needs to be sent to the user, but until the user interacts with that representation, the data source remains in whatever state it was when the most recent response was rendered... which is why, if you want a specific property of the data source to have a specific value before the user interacts with it, your code needs to set that property's value manually.
In summary, components are visual. Data sources are abstract. Perhaps this behavior would be more self-explanatory if the component property had simply been called defaultClientValue instead of defaultValue, because that's essentially what it is: a default suggestion to the user for what data to send back to the data source. But until they do, the data source has not received that value. So if, on initial page load, you need a data source property to have a value that it wouldn't already have in its default state, you should manually call setValue to give it the desired value.
P.S. Ironically, if you'd called partialRefreshPost instead of partialRefreshGet, you likely would have achieved the result you were looking for, because the former sends all the form data, while the latter just asks the existing component state to be rendered again. But then you're forcing all of the form data to be sent just to update one data source property, so it's better to simply do what's described above.

Web Services - default value ignores or clears a field?

We're developing a web service based on .NET webApi that will allow customers to create and update objects. When the model is handed to our controller, how do we differentiate between fields that are null/blank/0 because the caller wanted them set to null/blank/0, or fields that are null/blank/0 because that's the default used by parameter binding when the caller had no intentions of setting a value for that field? Is there a standard for dealing with this?
You should be able to just check the ModelState property on your controller. If a WebAPI action is invoked and the ModelState is valid, then it should mean that all the parameters were successfully bound from the URI or deserialized from the request body.
There's one caveat - this is only true for WebAPI's default parameter bindings. If you register your own custom parameter binding that binds the parameter differently, then all bets are off.
Now as far as properties and fields of parameters go, it's up to the formatter to decide how to handle those. Deserializers have two options when they encounter a member that's missing. They can either throw, or they can populate the member with 0/blank/null. You can ask the formatter to add a model state error when the property is missing by marking the property as [Required] or by using [DataMember(IsRequired=true)] if you're using the data contract model.