I'm using primefaces 4.0 and have a tabview with 4 tabs. When I click a button in one of the tabs I want to update all of the tabs but keep the current tab selected. However, when I update the tabview, the selected tab keeps getting set back to the first tab.
Is there a simple way to keep the current tab when updating the entire tabview?
You could use activeIndex attribut from tabView :
<p:tabView activeIndex="#{bean.activeIndex}"/>
From Primeface User Guide:
activeIndex is an Integer with default value 0. Index of the active tab.
In addition to the other answer there is one more thing: the activeIndex is actually a client-side index. That means that if you have unrendered tabs then you would have to compensate, so the unrendered tabs wouldn't count towards the index number. You can do it like this:
String targetTabClientId = "my_tabview:my_tab";
Tab targetTab = (Tab) FacesContext.getCurrentInstance().getViewRoot().findComponent(targetTabClientId);
TabView tabView = (TabView) targetTab.getParent();
int clientActiveIndex = 0;
for (UIComponent tab : tabView.getChildren()) {
if (tab.equals(targetTab))
break;
if (tab.isRendered())
++clientActiveIndex;
}
return clientActiveIndex;
You could on tab change store the tab index as a global JavaScript variable.
<script>
var activeIndex = 0;
function handleTabChange(event, index) {
activeIndex = index;
}
</script>
...
<p:tabView widgetVar="tabView1" onTabChange="handleTabChange(event, index)">
...
</p:tabView>
You could then on complete of a command restore the tab index from global JavaScript variable.
<p:commandButton ... oncomplete="tabView1.select(activeIndex)" />
This simple solution works for me.
this is my tab list which is like a header, maintained across all pages:
<h:form id="menuForm">
<p:tabMenu activeIndex="#{param.i}" >
<p:menuitem value="Admin" outcome="/administration/index.xhtml?i=0" >
<f:param name="i" value="0"/>
</p:menuitem>
<p:menuitem value="Marketing" outcome="/marketing/index.xhtml?i=1" >
<f:param name="i" value="1"/>
</p:menuitem>
...
</p:tabMenu>
</h:form>
And then, if I have a button that directs me to another page, my button looks like this:
<p:button outcome="/edit-user.xhtml?i=2" value="Edit User" />
You can see demo here: http://www.primefaces.org/showcase/ui/menu/tabMenu.xhtml?i=0
Related
I am doing an authentication in xamarin forms, using b2c, they asked me to embed the pop-up screen that triggers and in turn hide or eliminate both the cancel and the navigation bar, has someone done that part or otherwise modify it? (thanks in advance)enter image description here
Please check if below references can be worked in your case:
Hide Cancel button :
In custom policy:
Configure the setting.showCancelButton metadata item to false in the custom policy technical profile of the sign in or sign up or page for it is requiredrequired.
Example:
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
<DisplayName>Email signup</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="IpAddressClaimReferenceId">IpAddress</Item>
<Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
<Item Key="language.button_continue">Create</Item>
<Item Key=" setting.showCancelButton ">false</Item>
</Metadata>
<InputClaims>….
….
</TechnicalProfile>
See self asserted technical profile reference & Microsoft Q&A Reference
Through Xamarin Form:
For Xamarin forms ,Use Xamarin.Forms renderer to hide the "Cancel" button of a SearchBar on iOS using Control.ShowsCancelButton = false;
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
if (e.PropertyName == "Text")
{ Control.ShowsCancelButton = false;}
}
References:
Xamarin forms– iOS disable cancel button on SearchBar (weblogs.us)
How to handle/cancel back navigation in Xamarin Forms-Stack Overflow
Disable Navigation bar:
If you use webview in the NavigationPage or NavigationPage wrap the contentpage, Try to add NavigationPage.HasNavigationBar="False" into your contentPage tags like following xaml, to disable navigation bar.
Example:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:FormsWebViewTest"
x:Class="FormsWebViewTest.MainPage"
NavigationPage.HasNavigationBar="False">
...........
.......//other part
</ContentPage>
Or
SetHasNavigationBar to false on your navigation page (in content page constructor).
ex:
public MyPage()
{
InitializeComponent();
NavigationPage.SetHasNavigationBar(this, false);
}
I have created a Vaadin (7.4.3) accordion with a number of captions/tabs.
I need to be able to select a tab and check the contents within that tab.
However in the code below, even though the tab is found, the click() function
does not expand the tab and the contents of the tab remain unobtainable.
How can I check the contents of the tabs in an accordion?
Thank you...
List<WebElement> tabList = findElements(By.className("v-accordion-item"));
WebElement selectedTab = null;
for (WebElement tab : tabList) {
List<WebElement> captionElements = tab.findElements(By
.className("v-captiontext");
if (captionElements.size() > 0) {
if (captionElements.get(0).getText().equals("Caption_of_tab_to_be_checked")) {
// this is run
selectedTab = tab;
break;
}
}
}
selectedTab.click(); // the accordion does not open this tab and contents are still hidden???
TabSheetElement
tabSheetElement=$(TabSheetElement.class).id(TAB_AUTOMATIC_EMAIL);
tabSheetElement.openTab(2);
the Same you can check for multiple Tabs by adding click(); at last for example
tabSheetElement.openTab(2).click();
How can one achieve multiple form submission while the user holds the button pressed.
<h:commandButton value="Multiple submission" action="#{mngr.doSomething}"/>
Basically I just want to keep invoking mngr.doSomething method as long as i hold the button pressed. Any ideas?
That's only possible if you use <f:ajax> whereby you do not render the button itself. You can then use onmousedown and onmouseup events to start and stop the rage submit by explicitly invoking the onclick() handler of the button and you can use <f:ajax onevent> to continue explicitly invoking the onclick() handler on successful return as long as the button appears to be still pressed.
Here's a kickoff example:
<h:form>
<h:commandButton value="submit" action="#{bean.submit}" onmousedown="startRageSubmit(this)" onmouseup="stopRageSubmit(this)">
<f:ajax onevent="processRageSubmit" />
</h:commandButton>
</h:form>
(again, when using <f:ajax render>, make sure that the button is not covered by the selector)
with this JS:
function startRageSubmit(button) {
button.pressed = true;
button.onclick();
}
function processRageSubmit(data) {
if (data.status == "success" && data.source.pressed) {
data.source.onclick();
}
}
function stopRageSubmit(button) {
button.pressed = false;
}
You can add javascript event listener with javascript setInterval() function to submit the form(with AJAX) in your desire intervals.
I'm using jquery tab and following js method, how and what can i modify it to maintain state of tab between postbacks? (This resets tabs to first tab after page_load)
$(document).ready(function() { //When page loads...
$(".tab_content").hide(); //Hide all content
$("ul.tabs li:first").addClass("active").show(); //Activate first tab $(".tab_content:first").show(); //Show first tab content //On Click Event $("ul.tabs li").click(function() {
$("ul.tabs li").removeClass("active"); //Remove any "active" class
$(this).addClass("active"); //Add "active" class to selected tab $(".tab_content").hide(); //Hide all tab content
var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
$(activeTab).fadeIn(); //Fade in the active ID content return false; });
I ran across this problem when I first started using jQuery. My solution was to use an <asp:HiddenField /> to store the active tab index on tabselect.
ASP.Net allows client-side code to modify an <asp:HiddenField /> so it will retain its value across postbacks.
On document.ready, simply restore the active tab by setting the selected tab during intialization:
Example:
$('div#divMyTabs').tabs({
selected: function () {
var tabFromPostback = $('input#<%=hfActiveTab.ClientID %>').val();
return tabFromPostback === '' ? 0 : tabFromPostback; //Default to first.
},
select: function (e, ui) {
$('input#<%=hfActiveTab.ClientID %>').val(ui.index);
}
});
I am using telerik MVC control and I am having a popup window and I want to close the pop up window by firing click event from my cancel button on the popup window .
Can someone tell me how should I do it ?
This is what I did
<input type="button" value="Cancel" onclick="onClose()" />
and my java script is like this
<script type="text/javascript">
function onClose() {
window.close();
}
</script>
but when I do that I get a confirmation box asking me whether I want to close the window and If I select yes my browser window is closed.
I just did a similar thing with the asp.net-ajax window from telerik.
They have demos out that helped me.
Try http://demos.telerik.com/aspnet-mvc/window/clientsideapi for the mvc controls
You need to get a handle of the object
function GetRadWindow() {
var oWindow = null;
if (window.radWindow) oWindow = window.radWindow;
else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
return oWindow;
}
Then you can call close on the rad window object
function windowClose(reload) {
var oWindow = GetRadWindow();
oWindow.close();
}