Setting a value for composite data when property is in a group - xpages

I have a custom property in my custom control. The custom property is in the Field1 group and is called ClientID. The group and the field are in my custom property definition. I want to set it on page load. So I do the following:
compositeData.Field1.ClientID = getClientId("Field1")
When I do do I get an error:
'compositeData.Field1' is null
But if I define a property off of the root called Field1_ClientID and do the following:
compositeData.Field1_ClientID = getClientId("Field1")
Then all works well. How can I make use of groups in custom properties?

Bruce,
compositeData is a property map. If there is no value in it, compositeData.Field1 will be a null (because it is also a property map).
So you can do this;
compositeData.Field1= { ClientID: getClientId("Field1") }

To set the property "property1" within the group "group1" you can do the following:
compositeData.group1.property1 = "test";
You can run the above code in the beforePageLoad or afterPageLoad events of the custom control.
I think that your problem is that you are setting the value in an event which takes place before the custom control has been set up.

Ok I did a quick test of the group functionality of the custom control (never used it before).
given a group of "testGroup" and property of "testProp" inside that group.
The following worked in beforePageLoad:
compositeData.testProp = "example1";
print("Test1: " + compositeData.testProp);
the following did not work:
compositeData.testGroup.testProp = "example2";
print("Test2: " + compositeData.testGroup.testProp);
I therefore believe the group property may simply be a way of logically grouping properties and not defining an object with multiple properties. Try just referencing the property and not the group.

Related

When an Attribute is set to false, is the property still observable inside the element?

# lit-element -> Properties -> Configure attributes -> Configure observed attributes
it refers that:
By default, LitElement creates a corresponding observed attribute for all declared properties.
and
To prevent an observed attribute from being created for a property, set attribute to false. The property will not be initialized from attributes in markup, and attribute changes won’t affect it.
Clarification:
When an observed attribute is prevented, the property is still observable within the element, isn't it?
Tia
Yes. The property will still be accessible from within javascript, and will trigger re-renders.

Acumatica: Getting value of field on header from grid event

I'm new to Acumatica custom development and I'm trying to do something that I would assume is very simple. I have a Selector control (DataClass: FSServiceOrder, DataField: BranchLocationID) in the Sales Order header that allows user to set the Branch Location. Below, in an Inventory grid, I merely want to set the Warehouse field in the new row equal to the value of the above-mentioned selector. I can set Warehouse with a hard-coded value, but I have no idea how to reference the selector or get it's value, as it seems to be outside the scope of the passed PXCache object:
protected void FSSODetPart_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
string BranchLocationID = "" // Not sure how to get this value
var row = (FSSODetPart)e.Row;
cache.SetValueExt(row, "SiteID", BranchLocationID);
}
I was hoping I could simply reference all UI controls similar to ASP.NET, but that doesn't seem to be the case. Any help is appreciated. Getting a value from the screen seems to be fundamental but I cannot find any help in the documentation. Thanks.
In Acumatica screen controls are bound to DataViews.
DataViews contains DAC records. Common practice is to get the value from the current DAC record in the bound DataView.
Use the current object of the DataView holding FSServiceOrder DAC records:
string BranchLocationID = myDataview.Current.BranchLocationID;
If you don't know the DataView name, on the WebSite hold Ctl+Alt and click on the BranchLocationID UI field. A popup will appear showing the DataView name.
Getting the current object from the DAC collections should work too but it's preferable to use the DataView:
string BranchLocationID = Base.Caches[typeof(FSServiceOrder)].Current.BranchLocationID;
Also make sure you set the CommitChanges attribute to true on BranchLocationID form field in the Aspx file. This ensures that current object will fire events in the back-end when it's value is changed.
<px:PXSelector ID="edBranchLocationID" runat="server"
DataField="BranchLocationID" CommitChanges="True" />

java.util.ArrayList incompatible with [Ljava.lang.Object check box group

I have a Check box group, whose values are computed by using the selected values of another Check box group. So when I do
var check6:com.ibm.xsp.component.xp.XspSelectManyCheckbox = getComponent("check6");
ArrSelected = check6.getSelectedValues();
to get the selected values, the following exception occurs:
Error calling method 'getSelectedValues()' on java class 'com.ibm.xsp.component.xp.XspSelectManyCheckbox'
java.util.ArrayList incompatible with [Ljava.lang.Object;
Check6 gets its values from a session scope variable that is computed on beforePageLoad event and I have also set the default value.
Note that this does not happen onload of the page, but when the first partial refresh happens. Does anyone know what this exception indicates?
Thanks a lot!
Bind the value of the selectItems for the second check box group to precisely the same expression the first checkbox group's value attribute is bound to.
This article provides a lengthy description of the reason why, but here's a very quick summary: if you ask a component what its value is, it has to ask the data it's bound to. So skip the component, and ask the data yourself.
So, if your first group looks like this:
<xp:checkBoxGroup value="#{currentDocument.FirstField}">...
Then your second group should look like this:
<xp:checkBoxGroup value="#{currentDocument.SecondField}">
<xp:selectItems value="#{currentDocument.FirstField}">
</xp:checkBoxGroup>
When the user's selection in the first group is posted to the data source, the second group will reflect the changes because they're linked to the same property on that data source. Slight caveat: if your page includes any required fields, you may need to skip validation on the onchange event that triggers the second group to recalculate.
the reason is simple, this class has no method getSelectedValues() (as far as I can see it, look here for more info: http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/XPagesExtAPI/8.5.2/index.html?overview-summary.html)
Maybe you could bind the control to a scoped variable and then access this variable to compute your other values?

Programmatically hiding an SPField

I'm having trouble hiding a SPField from the user view programmatically.
I tried the obvious way of:
SPField newField = web.Site.RotWeb.Fields.GetField("order");
string newField = list.Fields.Add(newField);
list.Fields["order"].Hidden = true; // <--- exception: read-only field
list.Update();
The exception says the field is read only so I can't modify it.
This field is added in the code and hence it'll be unghosted from the field collection. Besides from the UI, how can I make the field hidden?
Thanks.
First, try setting ReadOnlyField to false (then back to true after setting Hidden).
If that does not work, check the value of CanToggleHidden. If CanToggleHidden is false, you can either:
Override it with reflection as in this example.
Add the field using XML as in this example. Note: if you need to use an existing site column, you can try adding ID attribute with the column's Guid to the XML string.
Skip Hidden and use ShowInDisplayForm, ShowInEditForm, and ShowInNewForm instead.
nevermind, I saw that you are adding the field. try getting a new instance of the field after it is created and then applying the hidden atttribute before updating the list.

Person & Group custom field type sharepoint

I have created a custom field type as it is there in sharepoint OOTB, the difference is only that the end user does not need to check the name i.e I have replaced it with DropDownList. The dropdownlist suggest the no. of users available in the web site for that I have created a FieldClass which inherits from SPFieldUser and a FieldControlClass which inherits from UserField. It is working fine in all conditions i.e when I create a List or Document Libarary it shows me the DropDownList
with respective users after saying OK it creates an item for me. I have overriden a Value property in FieldControlClass as follows,
public override object Value
{
get
{
SPUserCollection userscollection = rootWeb.SiteUsers;
//ddlInfoBox is a DropDownList to which I have Binded the collection of users in the form of string
SPUser user = userscollection.Web.EnsureUser(this.ddlInfoBox.SelectedValue);
SPFieldUserValue userval = new SPFieldUserValue(user.ParentWeb, user.ID, user.LoginName);
return userval;
}
set
{
SPFieldUserValue userval = (SPFieldUserValue) this.ItemFieldValue;
this.ddlInfoBox.SelectedValue = userval.Lookupvalue; //Here look up value is nothing but a Login name e.g In-Wai-Svr2\tjagtap
}
}
Due to above property the Custom Field's Value for this current ListItem will be stored as SPFieldUserValue e.g 27#;In-Wai-Svr2\tjagtap.
The main problem is here, when this particular ListItem is shown in the list page views e.g on AllItems.aspx or the custom view pages associated with it, it shows the
number as 27 as a FieldValue insted of HyperLink with text as "In-Wai-Svr2\tjagtap" and PostBackURL as "/_layouts/userdisp.aspx?ID=27".
When I edit this Item it makes the respective value selected in the dropdownlist, also while viewing this item i.e on DispForm.aspx it also shows the hyperlink. I have
acheived it by writting a custom logic in createchildcontrol() method i.e by using ControlMode if it is New or Edit then fill the dropdown list, if it is Display then get the ItemFieldValue Type Cast it into SPFieldUserValue and get corresponding lookupid and value for making the URL and showing Text of the HyperLink.
I have spent a lot of time on searching and bringing the HyperLink as the user name with navigation insted of UserID (27) as a string on the list view pages e.g AllItem.aspx but to no avail, then after a lot of research I found that there might be a way of achieving such kind of functionality by using field type definition xml file where there is a provision to define a DisplayPatteren as you wish by specifying the html code. But here is a problem How can I get the UserID (27) with respective UserName e.g In-Wai-Svr2\tjagtap inorder to make an anchor tag like In-Wai-Svr2\tjagtap which will solve my problem. I have hard coded this anchor tag within the Default case statement of a switch under DisplayPatteren but it shows me the field value on AllItems.aspx as
In-Wai-Svr2\tjagtap27 i.e the value defined in xml file is concatenating with the string value (27).
Please help me to resolve the above mentioned 2 issue. I am really in need of solving this problem ASAP.
Thanks & Regards,
Tejas Jagtap
Have u tried to override the GetFieldValueAsHtml() method in the the custom field class or maybe the RenderFieldForDisplay() method in the custom field control class.
Can you use the DisplayPattern CAML from the User field type?

Resources