Why does the Orbeon custom control tutorial stop showing when I change the name? - custom-controls

I am wanting to create a number of custom controls in Orbeon. Having had (seemingly) random success, I decided to go back to basics and start with the Tutorial.
After reading through the tutorial, I copied the basic component XBL into a file, linked it up in properties-local.xml, restarted Tomcat, went into Form Builder and clicked on the new control and it inserted the input with the label and hint into a new grid box on the form as to be expected (yay).
(here is the part of the properties-local.xml file that includes my tool)
<property as="xs:string" name="oxf.fb.toolbox.group.other.uri.*.*">
oxf:/xbl/play/slider/slider.xbl
oxf:/xbl/play/betterInput/betterInput.xbl
oxf:/xbl/play/sample/sample.xbl
</property>
I then tried to change the element name from fr|tutorial-input to fr|tutoria-input as below (a nice easy change I thought).
<xbl:xbl
xmlns:xh="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
xmlns:fr="http://orbeon.org/oxf/xml/form-runner"
xmlns:xbl="http://www.w3.org/ns/xbl"
xmlns:xxbl="http://orbeon.org/oxf/xml/xbl">
<xbl:binding
element="fr|tutoria-input"
id="fr-tutoria-input"
xxbl:mode="lhha binding value">
<xbl:template>
<!-- Input points to the external single-node binding -->
<xf:input ref="xxf:binding('fr-tutoria-input')"/>
</xbl:template>
</xbl:binding>
</xbl:xbl>
After, restarting Tomcat, going in to Form Builder and clicking on the new control again, it inserted an empty new grid box (no input, label or hint). Looking at the source of the form, it has inserted the input (see below) and the label and hint resources, just nothing shows.
empty grid box
<xh:tr>
<xh:td>
<tutoria-input xmlns="http://orbeon.org/oxf/xml/form-runner" id="control-19-control"
bind="control-19-bind">
<xf:label ref="$form-resources/control-19/label"/>
<xf:hint ref="$form-resources/control-19/hint"/>
<xf:alert ref="$fr-resources/detail/labels/alert"/>
</tutoria-input>
</xh:td>
</xh:tr>
I can changed the tutoria-input back to tutorial-input in the source code (without changing my code back), apply and it will show up in the form, so obviously it is running off the code included with Orbeon and using the magical something I am missing. I have even gone as far as to grep through the source to find all occurrences of tutorial-input to see if there was a file I was missing.
Please, what am I missing to get my tutoria-input custom control showing up as it should in Form Builder/Orbeon?

In order to be automatically found at runtime, components must be placed in folders named with the name of the XBL component. So in your case if you decide to name your component tutoria-input, you must place it under:
/xbl/orbeon/tutoria-input/tutoria-input.xbl

Related

Link directly to a notebook page in a view

I have an view that extends the current project view, where we add multiple tabs (notebook pages) to show information from other parts of a project.
One of these pages is an overview page that summarizes what is under the other tabs, and I'd like to link the headlines for each section directly to each displayed page. I've currently solved this by using the index of each tab and calling bootstrap's .tab('show') method on the link within the tab:
$(".overview-link").click(function (e) {
e.preventDefault();
var sel = '.nav-tabs a:eq(' + $(this).data('tab-index') + ')';
$(sel).tab('show');
});
This works since I've attached a data-tab-index="<int>" to each header link in my widget code, but it's brittle - if someone adds a tab later, the current indices will be broken. Earlier I relied on the anchor on each tab, but that broke as well (and would probably break if a new notebook page were inserted as well).
Triggering a web client redirect / form link directly works, but I want to show a specific page in the view:
this.do_action({
type: 'ir.actions.act_window',
res_model: 'my.model.name',
res_id: 'my.object.id',
view_mode: 'form',
view_type: 'form',
views: [[false, 'form']],
target: 'current'
});
Is there any way to link / redirect the web client directly to a specific notebook page tab through the do_action method or similar on FormWidget?
If I understood well you want to select the tab from the JavaScript (jQuery) FormWidget taking into account that the id could change if anybody install another module that adds another tab
Solution 0
You can add a class to the page in the xml form view. You can use the id of the element selected by this class name in order to call the right anchor and select the right tab item. This should happen when the page is completely loaded:
<page class="nb_page_to_select">
$('a[href=#' + $('.nb_page_to_select').attr('id') + ']').click()
NOTE: As you have said the following paragrah I assume that you know where to run this instruction. The solution I suggest is independent of the index.
This works since I've attached a data-tab-index="<int>" to each
header link in my widget code, but it's brittle - if someone adds a
tab later, the current indices will be broken. Earlier I relied on the
anchor on each tab, but that broke as well (and would probably break
if a new notebook page were inserted as well).
Solution 1
When the page is loaded you can get the tab list DOM object like this:
var tablist = $('ul[role="tablist"]')
And then you can click on the specifict tab, selecing by the text inside the anchor. So you don't depend on the tab index:
tablist.find('a:contains("Other Information")').click()
I think if you have two tabs with the same text does not make any sense, so this should be sufficient.
Solution 2
Even if you want to be more specific you can add a class to the notebook to make sure you are in the correct notebook
<notebook class="nt_to_change">
Now you can use one of this expressions in order to select the tab list
var tablist = $('div.nt_to_change ul.nav-tabs[role="tablist"]')
// or
var tablist = $('div.nt_to_change ul[role="tablist"]')
Solution 3
If the contains selector doesn't convince you because it should be equal you can do this as well to compare and filter
tablist.find('a').filter(function() {
return $.trim($(this).text()) === "Other Information";
}).click();
Where "Other Information" is the string of the notebook page
I didn't tried the solution I'm giving to you, but if it doesn't work at least may be it makes you come up with some idea.
There's a parameter for XML elements named autofocus (for buttons and fields is default_focus and takes 1 or 0 as value). If you add autofocus="autofocus" to a page in XML, this page will be the displayed one when you open the view.
So, you can try to add this through JavaScript, when the user clicks on the respective link -which honestly, I don't know how to achieve that by now-. But you can add a distinctive context parameter to each link in XML, for example context="{'page_to_display': 'page x'}". When you click on the link, I hope these context keys will arrive to your JS method.
If not, you can also modify the fields_view_get method (here I wrote how to do that: Odoo - Hide button for specific user) to check if you get the context you've added to your links and add the autofocus parameter to the respective page.
As you said:
This works since I've attached a data-tab-index="" to each header
link in my widget code, but it's brittle - if someone adds a tab
later, the current indices will be broken.
I assume that your app allow multi-user interaction in realtime, so you have to integrate somewhere in your code, an update part function.
This function will trig if something has changed and cleanout the data to rebuilt the index in order to avoid that the current indices will be broken.

Replace Orbeon Form with a new one asynchronously via AJAX

I am using Orbeon forms with Hybris. We have several pages linked together where a user needs to go through them in a sequence (checkout process).
The content of the Orbeon form is dynamically being determined based on actions from previous steps. E.g.
If user adds Product A to the cart on the step 1, only two fields will be visible on the form located on step 2, if he adds another (Product B) on step 1, one more field should be visible on the form.
I am using certain preprocessor class which prefills some of the hidden fields on the form and then the logic for dynamic display is on the Form itself, based on those hidden fields. This works in a simple scenario when moving back and forth, through the steps.
However, the problem is that I need to have a HTML Mini-cart displayed on the page as well (not part of Orbeon Form), which can also trigger adding/removing of the products asynchronously.
So while I am on step 2 where the form is displayed, the user can also remove/re-add some of the products -> therefore, this needs to trigger asynchronous re-rendering of the form and change the display of the form (with new fields added or removed).
I'm using AJAX for this async stuff and the problem I am facing is that a lot of Orbeon-specific Javascript files and variables is being generated when the page loads for the first time, and some random FormID is used. This FormID is different when I retrieve the new form from the back-end and when trying to replace the HTML content I'm getting various errors in the console, because old Form id is used all over the place.
Does anyone have any suggestion if this could be achieved and how to approach this problem?
Update: Example of "hidden" field glass-coverage-selected
<xf:instance id=""fr-form-instance"" xxf:exclude-result-prefixes=""#all"">
<form>
<glass-coverage-selected/>
<section-1>
<massive-exterior-walls/>
</section-1>
...
Later, a bind is created:
<xf:bind id=""section-40-bind"" ref=""section-40"" name=""section-40"" relevant=""instance('fr-form-instance')/glass-coverage-selected = 'yes'"">
<xf:bind id=""previous-glass-insurance-bind"" ref=""previous-glass-insurance"" name=""previous-glass-insurance"">
<xf:required id=""validation-156-validation"" value=""true()""/>
</xf:bind>
And that bind is used to control the visibility of certain section:
<fr:section id=""section-40-control"" bind=""section-40-bind"">
<xf:label ref=""$form-resources/section-40/label""/>
<fr:grid>
<xh:tr>
<xh:td>
<xf:select1 id=""previous-glass-insurance-control"" appearance=""full"" bind=""previous-glass-insurance-bind"" class=""previous-insurance"">
<xf:label ref=""$form-resources/previous-glass-insurance/label""/>
<xf:hint ref=""$form-resources/previous-glass-insurance/hint""/>
<xf:help ref=""$form-resources/previous-glass-insurance/help""/>
<xf:alert ref=""$form-resources/previous-glass-insurance/alert[1]"" validation=""validation-156-validation""/>
<xf:alert ref=""$form-resources/previous-glass-insurance/alert[2]""/>
<xf:itemset ref=""$form-resources/previous-glass-insurance/item"">
<xf:label ref=""label""/>
<xf:value ref=""value""/>
<xf:hint ref=""hint""/>
</xf:itemset>
</xf:select1>
</xh:td>
</xh:tr>
</fr:grid>
</fr:section>
You can manipulate the values of form fields in JavaScript, in the browser. If you want to set the value of "hidden fields", you make sure that those fields as not hidden by putting false() under Visibility for the field in Form Builder. If you do this, for security reasons, the value of the field isn't even sent to the browser by Orbeon Forms, and it can't be set from JavaScript. Instead, to be able to set the value from JavaScript, you need to hide the control with CSS. The simplest way to do this is to add the class xforms-disabled for that field in the Control Settings dialog.
Then, assuming the name of the control in Form Builder is my-control, in JavaScript you can write var control = ORBEON.jQuery('*[id $= "my-control-control"]'); ORBEON.xforms.Document.setValue(control.attr('id'), '42');. Note the -control added at the end of the name of the control. And to test this first, I recommend you don't put the CSS class, so you can more easily see if setting the value works.
For the documentation on the above setValue() and other JavaScript APIs, see the page Client-side JavaScript API.

Loading default XSLTForms subform on body onload event

I'm trying to use subforms and I had a problem: I saw the example provided in the oficcial XSLTForms but in that case the elements that load/unload the forms are always in the "main form" and, in my case, I need them to desappear, because I'm trying to build something like a wizard, So the first subform must desappear when the user press "Next" and then subform2 is loaded, and so on. This presents two problems:
1) If I include the first subform elements in the "main page", when I press the trigger the elements of subform1 are never unloaded. The other subforms do it, but that initial one is treated as part of the structure that never changes... And I really need to desappear. SO I think I have to put all the content of subform1 outside, in a separate xml and load it in the same way as the other subforms, but there is another problem:
2) I need it be loaded by default, and I tryed to put a load element directly in the main form body, but it didn't work.
I "patched it" temporally with a trigger in the main form, which loads the firms subform, but it is so... ugly, and I still have the same problem: I can navigate through subforms but that initial trigger never dissapears... So, any idea will be welcome! Thanks in advance!
<xf:model xmlns="" >
<xf:action ev:event="xforms-ready">
<xf:load show="embed" targetid="subform" resource="FirstSubform.xml"/>
</xf:action>
</xf:model>

kendoui validation tooltip in custom popup editor not positioning correctly

Please see jsfiddle for example, blank out First Name field to have validation tooltip show. In a normal form the validation tooltip positions correctly to the right of each element. But in the popup editor for the grid it still trying to position the tooltip below the element as if it where editing inline. I have tried <span class="k-invalid-msg" data-for="FirstName"></span>but it doesn't change anything. Is there a setting I am missing to get this working in popupeditor? I guess I could manually modify the .k-tooltip but I am hoping for something more built in that handles the positioning correctly, because I am not very good at css.
As you've discovered, the error template for the grid is different to that provided by the kendo validator when applied to standard inputs.
Unfortunately, the validator that is created internally by the grid does not pass along any errorTemplate that you might define in the options object and by the time the "edit" event fires, the validator has already been created and the error template compiled, hence why setting the errorTemplate in the manner you describe does not work. Really, I think the Kendo grid should respect any user defined errorTemplate option but until it does we have to hack a little bit.
The key is to define a custom template and to apply it in the edit event, but instead of using the options object, set the private instance directly. Not ideal, but it works:
edit: function (e) {
e.sender.editable.validatable._errorTemplate =
kendo.template($('#tooltip-template').html());
}
See this updated fiddle for an example of what I think you might be looking to achieve.
http://jsfiddle.net/nukefusion/eQ2j7/10/
(I would post this as a comment but not enough reputation yet...)
I'm successfully using nukefusion's solution. I, too, fought with the syntax error from jQuery for a long time and discovered through debugging that how you define the template is important. In particular, it appears that the template has to be written on a single line without any formatting, as in:
<script id="tooltip-template" type="text/x-kendo-template"><span class="k-widget k-tooltip k-tooltip-validation"><span class="k-icon k-warning"></span>#=message#</span></script>
If you try to make it "pretty" and format the html in the template, you get the syntax error. I don't know where the real bug is, as this sort of thing shouldn't cause an error. But it does and I stopped worrying about it once I got it to work correctly.

Dropdown in templated column for ultrawebgrid does not function properly

I have a templated column. I am using a Dropdown as header template and based on the value of the dropdown user sets, I update sigle DB record. Header drop down has nothing to do with the contents of the cells of that column. Everything works fine when the page is loaded and dropdown functions as expected.
As soon as I click anywhere on the gid and then click on the drop down, it behaves in a weird fashion i.e. it expands and then collapses. If I double click on the drop down it works as expected.
I am not able to understand what happens when I click inside the grid so that my drop down only responds to double click and not single click.
Here is the code snippet:
<igtbl:TemplatedColumn BaseColumnName="Assigned" Key="Assigned" AllowResize="Free" AllowRowFiltering="False"
AllowUpdate="Yes" Width="80px" Type="Custom" EditorControlID="assignTo" IsBound="false">
<Header Caption="Assigned To" ClickAction="SortSingle">
<RowLayoutColumnInfo OriginX="15" />
</Header>
<HeaderTemplate>Assigned To <select id="AssignToDefault" width="40px" runat="server" name="AssignToDefault"><option value="0">-Select-</option><option value="1">User</option><option value="2">API</option></select>
</HeaderTemplate>
<Footer>
<RowLayoutColumnInfo OriginX="15" />
</Footer>
</igtbl:TemplatedColumn>
I am trying to solve the issue since long. Please help.
Found the answer on Infragistics Community:
http://community.infragistics.com/forums/p/67149/340326.aspx#340326
EDIT (in case link deprecates):
I tested your scenario and was able to replicate the behavior in IE8 but not in Firefox.I suggest that you try disabling the activation behavior of the grid to see if that makes a difference:
UltraWebGrid1.DisplayLayout.ActivationObject.AllowActivation = false;
Alternatively you may want to consider using the WebCombo control in this scenario as it seems to be unaffected by the issue.
Please note that the UltraWebGrid control is now outdated and as of .NetAdvantage 2011 Volume 2 is no longer included in our product package. I would suggest that you consider switching to the WebDataGrid/WebHieararchicalDataGrid. More information regarding these controls is available at:
http://help.infragistics.com/NetAdvantage/ASPNET/2011.2/CLR4.0/?page=Web_WebDataGrid_WebDataGrid.html
Additional samples demonstrating the features of these grids can be found at:
http://samples.infragistics.com/aspnet/
Thank you :)

Resources