You need to sign in to do that
Don't have an account?
Pooja GL
User Language and Locale Values from VF page to Controller
I have a VF pafe which has fields to set language and locale vale, the code for the blcok is below.
<div class="form-group col-lg-12">
<apex:outputLabel for="languageInput" value="{!$ObjectType.User.Fields.languageLocaleKey.Label}"/>
<apex:inputField styleClass="form-control" value="{!u.languageLocaleKey}" id="languageInput" required="true" />
</div>
<div class="form-group col-lg-12">
<apex:outputLabel for="localeInput" value="{!$ObjectType.User.Fields.localesIdKey.Label}"/>
<apex:inputField styleClass="form-control" value="{!u.localesIdKey}" id="localeInput" required="true" />
</div>
I want to get the value selected on these 2 picklist fields and assign it during user creation on controller using an existing class and method.
User u = new user();
u = AccountMatchUtilityTEV.createExternalUserDuringRegistration(account, password, u.languageLocaleKey, u.localesIdKey, 'America/Los_Angeles');
But the new user created is always taking the default values (en_US and en_UK)
Please let me know what is wrong in the above lines of code.
<div class="form-group col-lg-12">
<apex:outputLabel for="languageInput" value="{!$ObjectType.User.Fields.languageLocaleKey.Label}"/>
<apex:inputField styleClass="form-control" value="{!u.languageLocaleKey}" id="languageInput" required="true" />
</div>
<div class="form-group col-lg-12">
<apex:outputLabel for="localeInput" value="{!$ObjectType.User.Fields.localesIdKey.Label}"/>
<apex:inputField styleClass="form-control" value="{!u.localesIdKey}" id="localeInput" required="true" />
</div>
I want to get the value selected on these 2 picklist fields and assign it during user creation on controller using an existing class and method.
User u = new user();
u = AccountMatchUtilityTEV.createExternalUserDuringRegistration(account, password, u.languageLocaleKey, u.localesIdKey, 'America/Los_Angeles');
But the new user created is always taking the default values (en_US and en_UK)
Please let me know what is wrong in the above lines of code.
Please Initialise the User (get, set one) in the constructor.
Also, if you are doing this in your register method, it will not at all set to the selection that you are doing on the VF Page.
All Answers
In the class and method AccountMatchUtilityTEV.createExternalUserDuringRegistration, user is being inserted.
and in the VF page I have a button which calls the function in which the below lines are present.
User u = new user();
u = AccountMatchUtilityTEV.createExternalUserDuringRegistration(account, password, u.languageLocaleKey, u.localesIdKey, 'America/Los_Angeles');
VF page button :
<div class="form-group col-lg-12">
<apex:commandButton action="{!register}" styleClass="btn btn-primary" value="{!$Label.Sign_Up_TEV}"/>
</div>
public User u {get; set;}
and In the controller I am using u.languageLocaleKey to access the value the user selected on VF page (suppose, User selects French, then u.languageLocaleKey will have the value French?). But I am getting 'Attempt to de-reference null object' on my VF page.
How to access the language value that the user selected in the Page?
Please Initialise the User (get, set one) in the constructor.
Also, if you are doing this in your register method, it will not at all set to the selection that you are doing on the VF Page.
Thanks for the answer. Initializing user record in the constructor solved my problem. :)