I am now getting my tabs in the Application Layout's TitleBar form a view, but it seems that managing the "selected" property is not wotking. Here is the code I have in my page:
<xe:this.titleBarTabs>
<xe:repeatTreeNode indexVar="1" var="tab">
<xe:this.children>
<xe:basicLeafNode label="# {tab.label}"
submitValue="#{tab.label}"
onClick="#{javascript:sessionScope.selectedTab = tab.label;}">
<xe:this.href><![CDATA[#{javascript:
"home.xsp?action=openDocument&documentId=" + tab.unid;}]]>
</xe:this.href>
<xe:this.selected>
<![CDATA[#{javascript:tab.label==sessionScope.selectedTab;}]]>
</xe:this.selected>
</xe:basicLeafNode>
</xe:this.children>
<xe:this.value><![CDATA[#{javascript:getTabs();}]]></xe:this.value>
</xe:repeatTreeNode>
</xe:this.titleBarTabs>
Can this be that hte Href and onClick cannot be there at the same time or I'm just missing something?
As usual, thanks a million for your help. Can't wait to give some back...
You have to decide what shall happen when user clicks a title bar tab:
open URL defined in href
OR
execute onClick event.
The help for onClick gives the hint:
So, you can't use onClick and a scope variable to appear a tab selected after user clicked on tab and new content shows up.
To accomplish this
add an URL parameter &tab= with the tab label tab.label to your href URL
return true in selected code if the current tab label is equal to the tab URL parameter
Your href and selected properties would look like this then:
<xe:this.href><![CDATA[#{javascript:
"home.xsp?action=openDocument&documentId=" + tab.unid + "&tab=" + tab.label}]]>
</xe:this.href>
<xe:this.selected>
<![CDATA[#{javascript:tab.label === param.tab}]]>
</xe:this.selected>
Don't forget to delete the onClick property in your code. You don't need it anymore.
Along the lines of what Knut is suggesting (I think) ... comment out the onClick property for the basicLeafNode and moves its function to the onItemClick for the xe:applicationLayout control.
The code for the onItemClick would be something like this...
var clickedTab = context.getSubmittedValue();
sessionScope.selectedTab = clickedTab;
Related
I would like to calculate the visibility of a button based upon the content of a text area field (multi line edit box). it should contain at least some text.
I could use the onkeypress event (server) and perform a partial refresh on the button BUT I notice that the partial refresh spinner appears then when users are writing in the field. I would like to avoid this.
What options do I have?
You would be best off writing a client side script for that event. This script should show the button when there are more than 200 characters in the textarea. You will need to set the style visibility to hidden for the button initially. If the form can be edited multiple times, you will need to write this as a function and call it on page load as well as in the keypress event.
If you can use the keyup event instead of keypress, this may be better.
var textareaID = '#{id:textareaID}';
var buttonID = '#{id:buttonID}';
var textareaValue = document.getElementById(textareaID).value;
var visibility;
if (textareaValue.length > 200) {
visibility = 'visible';
}
else
{
visibility = 'hidden';
}
document.getElementById(buttonID).style.visibility=visibility;
I wonder, if someone has THE CLUE for me on one of my devel problem (sure you do ;-) ).
I try to use a "Dojo Tab Container" with dynamic Dojo Tab Panes.
<xp:div id="tabs">
<xe:djTabContainer id="djTabContainer1" tabPosition="top"
style="height:250px;width:500px" defaultTabContent="defTab">
<xp:this.facets>
<xe:djTabPane xp:key="defTab" id="myTab" partialEvents="true" closable="true">
<xp:panel>
<xp:label value="#{javascript:getComponent('myTab').getTitle()}"></xp:label>
</xp:panel>
</xe:djTabPane>
</xp:this.facets>
</xe:djTabContainer>
</xp:div>
Then there's a SSJS (button) event to add tabs (actually the action is more complex to calculate title etc., but this should explain):
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
cont.createTab({id:'tab1', tabUniqueKey:'tab1', tabTitle:'tab1'});
cont.createTab({id:'tab2', tabUniqueKey:'tab2', tabTitle:'tab2'});
cont.createTab({id:'tab3', tabUniqueKey:'tab3', tabTitle:'tab3'});
Now I want to programmatically switch (open) to another tab, or close a tab. It's quite difficult to find useful examples here.
I found out, that I can programmatically switch to another tab via cont.setSelectedTab('2') instead of cont.setSelectedTab('tab2') - as I would expect. For some reason the tabUniqueKey parameter is fully ignored, while the tabTitle parameter isn't. Even worse: it looks like all createTab()-parameters are ignored, except of tabTitle.
Is there an elegant way to get the tab pane component? getComponent('tab2') doesn't work. Neither "id:'tab2'" nor "tabUniqueKey:'tab2'" are taken in account. I can get a tab using getComponent('myTab'), but that's fully useless, if all tabs have the same id.
So, neither does
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
var tabSel:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = comp.selectTab('tab2');
nor
var tabSel:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = comp.setSelectedTab('tab2');
At least what I'm looking for is something similar to:
cont.closeTab('tab3'); // to close tab3
createTab() returns a UIDojoTabPane pane object and you can use it to select the created tab afterwards:
var cont:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabContainer = getComponent('djTabContainer1');
var paneTab1:com.ibm.xsp.extlib.component.dojo.layout.UIDojoTabPane = cont.createTab({id:'tab1', tabUniqueKey:'tab1', tabTitle:'tab1'});
...
cont.setSelectedTab(paneTab1.getTabUniqueKey());
You can use this pane object to close the tab too:
paneTab1.closeTab()
While adding component dynamically, 'this.container is null' is displayed in firebug.
I have a window with some combo boxes say combo1, combo2, combo3 and a label. Based on the selection value of combo3 the 'label' field is removed and replaced with combobox or text field. i do this my using
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
The form resides inside a panel.
When above lines are execueted. 'this.container is null' is displayed and component fails to insert/add in appropiate position.
Any suggestions?
You should not be modifying the underlying items collection. Use the remove/insert methods on the container.
Try to comment those lines line-by-line to see which one produces error like
form.items.removeAt(4);
//form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
//form.doLayout();
form.items.removeAt(4);
form.items.insert(4, newItem); #here newItem can be combox/textfield
form.doLayout();
Your problem could take place because of inserted/replaced object is no yet prepared when you try to insert it. Give us your newItem initilization code.
Upd
Or you can wrap your changing components (label, combobox, textfields) in a panel with card layout. And on change of combo3 simply select exact card in that panel.
I know it's possible to use a legend to turn on/off flot series, as can be seen on this page.
In that example, the change seems to be the result of the click event.
I'm trying to get this to also work when an onchange event is used.
If I (add and then) click this button...
<input type="button" value="Disable USA" onclick="document.getElementById('idusa').checked = false;">
...the checkbox is being disabled, but the graph isn't being redrawn.
I tried to fix this issue in two ways:
I added plotAccordingToChoices(); to the onclick of the button, and
I changed the choiceContainer.find("input").click(plotAccordingToChoices); code: tried using change instead of click.
This didn't work. Any ideas?
This is a really tough problem, as far as I know (and I don't know that much) changing the checkbox from the button will not fire its change event, but since you're using a function, you can just change the attribute, then fire the redraw function. I also changed the .click() to .change() just for effect:
From Flot code, I added a class to each element and set that class to have a change event:
choiceContainer.append('<br/><input type="checkbox" name="'
+ key+'" checked="checked" id="id' + key + '" class="legend">' +
'<label for="id' + key + '">' + val.label + '</label>');
$(".legend").change(plotAccordingToChoices);
Now for your button, I made it toggle USA:
$("#clicker").click( function(){
if($("#idusa").is(":checked"))
$("#idusa").attr('checked', false);
else
$("#idusa").attr('checked',true)
plotAccordingToChoices();
});
EDIT:
You can use .trigger('change') to fire the change event.
$("#clicker").click( function(){
if($("#idusa").is(":checked"))
$("#idusa").attr('checked', false);
else
$("#idusa").attr('checked',true)
$("#idusa").trigger('change');
});
Finally I changed the button to a button:
<button id="clicker">Disable USA</button>
You could modify this a little and have a button for each checkbox if you wanted.
I hope this works for you.
I would like to move "click heading to sort" to "double click heading to sort". So currently i'm doing it with the following two lines:
table.unsubscribe("theadCellClickEvent", TAG.content.table.onEventSortColumn);
table.subscribe("theadCellDblclickEvent", TAG.content.table.onEventSortColumn);
However, when i do this, and i click on the heading, it will take me to folder/thead-id (since by default there is a "a" tag wrapped around the heading text.
Any idea how to do it properly?
Thanks a lot!
Jason
You have to stop the default click event. Create a new event handler for the click event that simply stops bubbling the event.
var stopEvent = function(oArgs) {
var evt = oArgs.event;
YAHOO.util.Event.stopEvent(evt);
};
table.unsubscribe("theadCellClickEvent", TAG.content.table.onEventSortColumn);
table.subscribe("theadCellClickEvent", stopEvent);
table.subscribe("theadCellDblclickEvent", TAG.content.table.onEventSortColumn);