Data binding of lightning:input and aura:attribute with type sObject(field) is not working - salesforce-lightning

There is a weird scenario I'm facing while I try to bind the markup UI tags with lighting aura:attribute as type sObject (fields).
I'm trying to bind data to sobject's fields for different lightning:input tags,
For one sObject attribute the binding works perfect, but in the same way for another sObject the data is not getting bound.
For Ex:
<aura:attribute name="student" type="JN_Student__c" access="global" default="{'sobjectType' : 'JN_Student__c'}" />
<lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name"value="{!v.student.JN_Last_Name__c}" maxlength="20" required="true"/>
this works perfectly and the data persists as I show/hide this section.
WHEREAS for,
<aura:attribute name="insuranceInstance" type="JN_Insurance__c" access="global" default="{'sobjectType' : 'JN_Insurance__c'}" />
<lightning:input aura:id="requiredVal" name="lastName" label="Legal Last Name" value="{!v.insuranceInstance.Name}" maxlength="20" required="true"/>
the 'v.insuranceInstance.Name' doesn't persists its value.
Please reply if anyone knows/encounted the same.

Related

How to Add additional columns to links page to ExternalLink types

How to add columns to ExternalLink on the "Links" page on Azure DevOps Workitem ?
Answered : Not Possible see answer below
Pull Request is not like Code Review Request, it's not a work item
type, we cannot see it from the exported process template. So, I don't
think we can customize the columns like the common work item types. –
Andy Li-MSFT
after going through the following links
link1
link2
and trying the workaround discussed here
I have failed to add more columns to links of the type externallink
i have added the following code as described:
<Page Label="Links" LayoutMode="FirstColumnWide">
<Section>
<Group Label="links">
<Control Type="LinksControl" Name="links">
<LinksControlOptions>
<LinkFilters>
<ExternalLinkFilter Type="Build" />
<ExternalLinkFilter Type="Integrated in build" />
<ExternalLinkFilter Type="Pull Request" />
<ExternalLinkFilter Type="Branch" />
<ExternalLinkFilter Type="Fixed in Commit" />
<ExternalLinkFilter Type="Fixed in Changeset" />
<ExternalLinkFilter Type="Source Code File" />
<ExternalLinkFilter Type="Found in build" />
<ExternalLinkFilter Type="GitHub Pull Request" />
<ExternalLinkFilter Type="GitHub Commit" />
</LinkFilters>
<Columns>
<Column Name="System.State" />
<Column Name="System.ChangedDate" />
<Column Name="System.PullRequest.IsFork" />
</Columns>
</LinksControlOptions>
</Control>
</Group>
</Section>
</Page>
But the results still show only the original columns.
The problem is that the field/column you added (<Column Name="System.PullRequest.IsFork" />) is not a valid work item filed/column. The workaround is only available for work item types due to the columns depend on work item fields.
You need to add a valid work item field/column here. We can get all the available work item fields by calling the Get Work Item REST API with parameter $expand=Fields added in the URL from a specific work item.
GET https://{instance}/{collection}/{project}/_apis/wit/workitems/{id}?$expand=Fields&api-version=4.1
For example, the following screenshots shows all the available fields for my Task work item. (It depends on how you defined the fields, if you defined a custom field, you can also see it from the response body.):
After that, we can add the columns (System.CreatedBy and Microsoft.VSTS.Common.Priority for example in this sample)
Then check the behavior in a Task work item:
Please note that, Pull Requests is not a work item type. We cannot get valid work item fields by calling the Pull Requests REST API. In this case, I don't think we can customize the columns like the common work item types.

How to add pre-defined values on "Found in Environment" field

AzureDevOps has a a filed called "Found In Environment".
I want to add this to my work items, however I would like to setup a predefined list of values that the user should select.
I can do this by adding a new custom filed, but It would be strange to add custom filed for a filed that AzureDevOps already have.
Question: Is there any way to configure a predefined set of values for already existing filed?
Actually, Azure DevOps just support users to customize the values for any system picklist(except the reason field) such as Severity, Activity, Priority, etc. You can refer to here to get the information about customize system picklist values.
As my test, the Found in Environment field only support one default value, not picklist items.
So according to your question, some fileds can configure set of values for already existing field, but not the Found in Environment field.
Or you can use XML to customize your own process and fields value by your rule. Below is a simple sample about how to definition a work item picklist items in XML.
In addition, only after Migrate from tfs to azure devops, you will have edit xml options. About XML, you can refer to here
<FIELD name="Priority" refname="Microsoft.VSTS.Common.Priority" type="Integer" reportable="dimension">
<HELPTEXT>Business importance. 1=must fix; 4=unimportant.</HELPTEXT>
<ALLOWEDVALUES expanditems="true">
<LISTITEM value="1" />
<LISTITEM value="2" />
<LISTITEM value="3" />
<LISTITEM value="4" />
</ALLOWEDVALUES>
<DEFAULT from="value" value="2" />
</FIELD>

Form Input field with name="url" is not working

I am using a form in jsp. One of the input fields is a text field with name set to 'url'
URL:<input id="url" name="url" type="text" />
When i submit this form, it throws a blank page and the console doesnt tell me anything. When I change the name to name="VenURL", then the form returns an appropriate response.
Is there a restriction on naming an input form field ?

Ignore custom validation, but not the required="true" depending on button pressed

I am using JSF and I want to validate a form.
In the form is a text field that is validated by required="true" and a validator method.
<h:inputText
required="true" requiredMessage="Please enter a topic"
validator="#{eventController.validateTopic}" />
To submit the form I have two buttons. When clicking on the first, it should be only validate if the field is empty. By the second one the custom validation should be additionally invoked.
Is this possible?
First turn that validation method into a true Validator implementation.
#FacesValidator("topicValidator")
public TopicValidator implements Validator {}
Then you can use it in a <f:validator> which supports disabled attribute.
<h:inputText ...>
<f:validator validatorId="topicValidator" disabled="..." />
</h:inputText>
To let it check if a certain button is pressed, just check the presence of its client ID in the request parameter map.
<h:inputText ...>
<f:validator validatorId="topicValidator" disabled="#{empty param[secondButton.clientId]}" />
</h:inputText>
...
<h:commandButton binding="#{secondButton}" ... />
Note: do absolutely not bind it to a bean property! The above code is as-is. You should only guarantee that the EL variable #{secondButton} is unique in the current view and not shared by another component or even a managed bean.
See also:
How to let validation depend on the pressed button?
How does the 'binding' attribute work in JSF? When and how should it be used?

Why the form id prefix in the h:message output?

I'm currently trying simple validation using required="true"
<h:form>
<h:messages globalOnly="true"/>
<h:panelGrid>
<h:panelGrid columns="3">
<f:facet name="header">
Login Application Sample
</f:facet>
<h:outputLabel for="UserId" value="User Id" />
<h:inputText id="UserId" value="#{userBean.userId}" required="true" />
<h:message for="UserId"/>
<h:outputLabel for="Password" value="Password" />
<h:inputSecret id="Password" value="#{userBean.password}" required="true" />
<h:message for="Password" />
<f:facet name="footer">
<h:commandButton value="Login" action="#{userBean.login}"/>
<h:commandButton type="reset" value="Reset"/>
</f:facet>
</h:panelGrid>
</h:panelGrid>
</h:form>
Leaving the fields blank, and then clickin on the login button, these error messages will display on the right side of each field :
j_idt7:UserId: Validation Error: Value is required.
j_idt7:Password: Validation Error: Value is required.
This is what I expected, but I don't want to display the form id prefix of 'j_idt7:'. I read book examples, they don't output the form id prefix. What I want is :
UserId: Validation Error: Value is required.
Password: Validation Error: Value is required.
What should I do to skip displaying the form id prefix in the component specific messages ?
I'm currently testing JSF 2 in glassfish v3.
The message label defaults to component's client ID, exactly the one as you can see in generated HTML output via rightclick, View Source. That j_id7 is in this particular case the client ID of the parent <form> element. If you give the JSF component a fixed ID like <h:form id="login"> then the labels will become login:UserId and login:Password respectively.
You can however use the input component's label attribute to override it altogether so that the message label will be shown exactly as you intented.
<h:inputText ... label="User ID" />
<h:inputSecret ... label="Password" />
If the input component's label attribute is present, then it will be used instead of the client ID. Using prependId="false" as suggested by other answers has disadvantages. Don't do that.
A completely different alternative is to use requiredMessage (or converterMessage or validatorMessage) attribute for this, but this doesn't allow parameterizing messages and thus you'd have to hardcode the labels and such.
<h:inputText ... label="User ID is required." />
<h:inputSecret ... label="Password is required." />
See also:
Change the default message "Validation Error: Value is required" to just "Value is required"
Getting the component id on the error validation message
How to parameterize requiredMessage attribute in composite component?
Noted should be that it's indeed awkward to have labels duplicated like this:
<h:outputLabel for="userId" value="User ID" ... />
<h:inputText id="userId" ... label="User ID" />
<h:outputLabel for="password" value="Password" ... />
<h:inputSecret id="password" ... label="Password" />
If you happen to use JSF utility library OmniFaces, then you can use <o:outputLabel> to let JSF transparently set the label attribute of the associated component:
<o:outputLabel for="userId" value="User ID" ... />
<h:inputText id="userId" ... />
<o:outputLabel for="password" value="Password" ... />
<h:inputSecret id="password" ... />
If you use MyFaces and the bean validation framework (JSR303) try to define a MessageBundle with a key javax.faces.validator.BeanValidator.MESSAGE
faces-config.xml
<application>
<message-bundle>ApplicationMessages</message-bundle>
</application>
ApplicationMessages.properties
#javax.faces.validator.BeanValidator.MESSAGE={1}: {0}
javax.faces.validator.BeanValidator.MESSAGE={0}
Details
You need to override these messages from JSF.
You can have a messages.properties file in your classpath
Messages.properties
javax.faces.component.UIInput.REQUIRED=Field must be entered.
Faces-config.xml
<application>
<message-bundle>Messages</message-bundle>
<locale-config>
<default-locale>en</default-locale>
</locale-config>
</application>
Have a look at this Article
If you care to see the HTML source from your browser, you will find out that the id of your input field is <form-id>+":"+<input-field-id>, in your case, j_idt7:UserId:. Try to give your <h:form> some meaningful id in order to make some sense out of it. You can read about JSF IDs here. In case you don't like it, you can turn it off by modifying your form tag to something like this,
<h:form prependId = false> // its true by default.
But that might turn out to be problematic, as pointed out by BalusC here.
Furthermore, it seems like you have never configured any validation messages yourself. Which in turn ends up with this message. Hence, a message.properties file is needed to have a control over message and show something more appropriate. Even then the field name should not be the part of the message, to make those validation message generic to avoid repetition. See BalusC's answer regarding the use of label attribute inside the <h:inputText>.
Where you are writing required = true, there you can define requiredMessage = "My Message" for any input type.
e.g.
<h:inputText autocomplete="false" id = "CellNumber" label="Cell Number" required="true" requiredMessage="Cell Number Required" maxlength="10" value="#{userManagedBean.cellNumber}" >