A couple of previous posts have already demonstrated the good use of the IP14 Control Plugin-wrapper framework. Today again another simple use-case to demonstrate its potential.
In Open UI it turns out that selecting (or better changing) the value of a check box can be cumbersome. Especially if you want to quickly modify its value in a list applet. Form applets are just fine. Most important of all you need to quite correctly point your cursor on a relatively small area. Further the element containing the check box needs to have focus too, before you can change it.
Experimenting a bit I created a new control plugin-wrapper.
Of course starting-off some solid boiler plate code…!
Implementing the AttachPW event
The usual set-up of a PW requires the implementation of the AttachPW event. This event basically defines for what type of control such as a Dropdown, MVG or Link it should act upon. From the Bookshelf you can get the available controls including the constant value Siebel works with internally. For a Check box this appears to be “SWE_CTRL_CHECKBOX”.
The AttachPW conceptually acts like a bouncer in a bar. It decides if the control’s behavior will be overridden or not. The bouncer will return true, what will make the PW control events to execute. By returning false, well nothing will happen.
From a development perspective, creating plugin-wrappers should be considered carefully, since they could have a widespread impact. A simple typo or a statement which throws an (unhandled) error could make your whole Siebel application could be negatively affected. Further, since the effect of a plugin-wrapper is more or less global, we should refrain from too heavy or process-expensive code.
The AttachPW event allows us to prevent execution of override code, in case this is either not required or would potentially not work at all given the context a certain control type is rendered within.
In this example, I just bluntly return “true”, it passes.
Implementing the ShowUI event
Next, the actual code. All within the ShowUI event.
To get the control’s element is simply done by using the GetEl() method on the object. Following that we need to find the gridcell in the list applet to which the Check box is tied. By testing whether we actually received a value element we select upwards the DOM the closest gridcell.
If that results in a valid element, we can attach a double-click even to it. Whether you use JQuery style or otherwise to bind an event to an element is irrelevant. I opted for JQuery style.
Finally, to make things not more complicated than necessary, I simply simulate and end-user click, again in JQuery style. For that one can use the “trigger” method.
The Out-of-the-box Siebel code will process the event further and “Bob’s you uncle”!
Enjoy and grab the full content here.