How to use values from business layer in Siebel Open UI Plug-in Wrapper
3. 5. 2017
We had a challenge to make applet and it‘s controls read only based on value of a calculated field. Lets assume we have a Business Component Action and calculated field „BC Read Only Field“. Based on value true or false we need with plug-in wrapper make the controls read only.
We decided to use Siebel Open UI Plug-in Wrapper for the controls of a form applet. Plug-in Wrapper is introduced with Siebel since IP2014. This way the logic applies to all applets based on condition. Some documentation about plug-in wrapper can be found here :
https://docs.oracle.com/cd/E63029_01/books/ConfigOpenUI/customizing_example004.htm
The documented techniques to add condition included control name, applet name or view name to attach the wrapper to a control. Examples are :
SiebelApp.S_App.PluginBuilder.AttachPW(consts.get("SWE_CTRL_COMBOBOX"), SiebelAppFacade.ColorBoxPW, function (control) {
return (control.GetName() === "Probability2");
or
SiebelApp.S_App.PluginBuilder.AttachPW(consts.get("SWE_CTRL_COMBOBOX"), SiebelAppFacade.ColorBoxPW, function (control) {
return (objName === "Activity Form Applet");
Our requirement was to use Business Component Field Value "BC Read Only Flag“ from BC Action. It is important to note that our approach need the control having in the applet either visible or hidden
We have writen function to retrieve the BC Value :
function compute_RO_result (control,objName) {
//This function has the logic to decide for BC Action Applets whether they need to be RO or not
var result = false;
var oApplet = control.GetApplet();
sBCName = oApplet.GetBusComp().GetName();
if (sBCName == "Action") {
var busObj = SiebelApp.S_App.GetActiveBusObj();
var busComp = null;
var bROFlag;
if (busObj != null)
busComp = busObj.GetBusCompByName(sBCName);
if (busComp != null)
bROFlag = busComp.GetFieldValue("BC Read Only Flag");
if (bROFlag == true)
result = true
else
result = false;
busComp = null;
busObj = null;
bROFlag = null;
sBCName = null;
oApplet = null;
}
return result;
In order to attach the wrapper the function looks like :
SiebelApp.S_App.PluginBuilder.AttachPW(consts.get("SWE_CTRL_COMBOBOX"), SiebelAppFacade.BCActionROPW, function (control, objName) {
return compute_RO_result(control, objName);
});
where the condition to attach the wrapper is used the result of this function.
To make control read only we used :
BCActionROPW.prototype.SetState = function (state, flag, index) {
// SetState is called when the framework needs to set the control state.
// state will be one of
// consts.get("EDITABLE")
// consts.get("ENABLE")
// consts.get("SHOW")
// consts.get("FOCUS")
// flag will be true or false
// Add code here that should happen before default processing
if ((state == consts.get("EDITABLE")||(state == consts.get("ENABLE"))) && flag == true) {
flag = false;
//workarounds for SWE IDs which are not working
$(".siebui-ctrl-datetime").attr('readonly', 'true');
$(".siebui-drilldown-input").attr('readonly', 'true');
$(".siebui-ctrl-checkbox").attr('readonly', 'true');
}
//SiebelJS.Log("BCActionROPW: SetState method reached.");
SiebelAppFacade.BCActionROPW.superclass.SetState.apply(this, arguments);
// Add code here that should happen after default processing
}
return BCActionROPW;
}()
);
The jquery expression for 3 objects are used because there seems to be bug in IP15 PS18 and Plug-in wrapper doesn‘t influence those controls. So we used this workaround.
The whole code can be found here :
The PW is powerfull point to influence controls for all applets in the application. You can argue that we can use BC User Prop, but we wanted to avoid these for many reasons and problems we had with them in correlation with our requirements.
Enjoy Open UI.
CCW Team.
Späť na Blog