Is it possible to add dynamic tabs (unrelated tabs) with out reloading the page using prime face.
I want to do some thing like this
http://blog.favrik.com/examples/tabs/
we will have a menu bar, and when a menu is clicked,a dynamic tab to be created.
The tab should load a page(xhtml), the tab should be added with out full page reloading and no dependency on any managed bean (as we are trying to be maximum stateless using mostly request scope)
I have seen example showing adding tabs based on bean data. But in my case each tab are independent (pages)
I have added a sample Image from the current flex application,(trying to migrate it to JSF) on what I am trying to do. Each tab is like a independent screen/xhtml file. No view state saved in server. when a menu item is clicked, a new tab is added with the new screen content. on page reload the tabs will be lost (which we can live with it as we are trying to be stateless)
You might need to flesh out your question more with more detail as to what you'll place in the tab. But try this :
Bind your client side TabView to an instance in the backing bean. On the xhmtl side :
<p:tabView id="myTabPanel" binding="#{myBackingBean.tabView}" />
in the backing bean
TabView tabView = new TabView();
//getter and setter
Implement the snippet below in a method to add a Tab as a child of the TabPanel
TabView tabView = new TabView();
Tab newTab = new Tab(); //Create new Tab
newTab.setTitle("Tab Title"); //Set a basic property
tabView.getChildren().add(newTab); //Add as a child of the TabView
Use primefaces RequestContext to ajax update the view to reflect the new tab
RequestContext context = RequestContext.getCurrentInstance();
context.update("myTabPanel");
Alternatively, like 7SpecialGems pointed out, you could simply just bind your TabView to a backing bean list and simply add a new item to that list, updating the TabView with RequestContext as indicated in 3. above to reflect the changes
Related
In my Prism application, I have a ribbon which I want to be able to update with context commands based on the currently active view and view model. I have my ribbon updating with context commands when a view is opened initially (in OnNavigatedTo), but I can't figure out how to update my ribbon as the user clicks between items in my tab control.
I'm planning on using Prism's IEventAggregator to send an "active view changed" event when the user clicks on a new tab, and then have each view model subscribe to that event and have the view model update the ribbon if the active tab item is that view model's tab. The problem is that I need my event data to include some parameters that specify what the active tab contains, but I don't know how to determine which view model is linked the active tab control item.
How do I know what view model corresponds to a tab control item, or is there another way of solving this problem?
You can just let the view model of the selected tab do the work, no need to over-complicate things:
xaml:
<TabControl SelectionChanged="OnSelectionChanged"/>
code-behind:
private void OnSelectionChanged( object sender, SelectionChangedEventArgs e ) => (((sender as TabControl)?.SelectedContent as FrameworkElement)?.DataContext as IRibbonAwareViewModel)?.OnSelected();
interface implemented by the tab's view model:
internal interface IRibbonAwareViewModel
{
void OnSelected(); // <-- here the view model updates the ribbon
}
I am facing a difficulty in displaying the properties of an object passed from an amx page to another. My aim is to display all the fields of an object of class employee{String name,int age,String phone} on a separate amx page. But I'm only able to display the name field.
Here is my empList.amx
Here is my EmpDetails.amx
The reultant display on my simulator for EmpDetails.amx shows just the employee.name property and nothing else
You have to manually add other properties in to the bindings. Here you added only the 'name' property in the row. name property automatically bind with the Listview object while drag and dropping ListView component from the palette.
Follow the below procedure
Select the bindings tab in the amx page where you defined the
ListView.
Select the object collection and click on the edit button (pencil).
Inside the edit popup, drop the needed properties in to the binding
region and click apply button
otherwise add the values manually in the *************pageDef.xml
file. Xml link provided in the bindings tab.
One of the properties in my model is decorated with Hide attribute. When I load a page this property is not displayed (as expected). When I click "Back" and then "Forward" buttons, essentially navigating away and then back, then this property shows. When I do a refresh then property is hidden away. Why?
Model is rendered via custom edit template.
I am trying to dynamically fill a second panorama page based on what item was selected from the home application screen.
On the application's first start screen there is a listbox if items each with text. If a user taps on an item with text "foobar" a template page should load and the title of the template page should be set to "foobar" and this second panorama page should know that it's data should be related to "foobar".
Is there anyway to do this?
I currently have my MainPage navigate to a new page (DynamicPage.xaml). This navigation is triggered when a ListBox_SelectionChanged event occurs. I have the title text of the DynampicPage.xaml Binding to a TitleText variable that is located in MainPage.xaml.cs. However, when I do this the title of DynamicPage.xaml is ever only set to my initialization value for the titleText variable even though I am updating this variable right before I navigate to the page.
If anyone can provide some help I would be very grateful as I am just a beginner on the WP7 platform. Thanks!
The Binding you're using for the title is only going to update if the TitleText property is a dependency property or if your MainPage is implementing the INotifyPropertyChanged interface so your class can notify the UI when one of its properties changed.
http://windowsphonegeek.com/articles/All-about-Dependency-Properties-in-Silverlight-for-WP7
http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.95).aspx
But I think this is not the best way for you to achieve this. For now a much better way is to store your data somewhere in a static class, in the main page's constructor load these data into the listbox, and when the user selected an item, navigate the user to the second page like this:
NavigationService.Navigate(new Uri("/DynamicPage.xaml?Item=" + selectedItem.Id, UriKind.Relative));
When you navigate like this a new instance of DynamicPage is created, and in the OnNavigatedTo method you can access the navigation parameters and populate your page with the selected data. For example:
<controls:Panorama x:Name="MyPanorama" Title="TitleHere">...</controls:Panorama>
Item selectedItem = StaticData.GetItem(NavigationContext.QueryString["Item"]);
MyPanorama.Title = selectedItem.Name.ToUpper();
Description.Text = selectedItem.Description;
This way you can use secondary tiles and toast notifications to directly point to a specific content in your application.
If you're getting to understand the navigation you should definitely use the pattern called Model-View-ViewModel which is about to solve these problems mostly with bindings, but trust me, probably this is the easier way for now.
I have binded RadCombo on LoadonDemand Event. when i change page of radgrid, RadCombo looses its selected item.
How to maintain RadCombo selected item.
Please Help
Have you tried using the RadComboBox's trackChanges() and commitChanges() methods to preserve the selected item across post-backs?
http://www.telerik.com/help/aspnet-ajax/combobox-client-side-radcombobox.html
I'm assuming the RadGrid is not contained in a RadAjaxPanel because if it were this would be taken care of automatically through partial page rendering (i.e. only the RadGrid would be re-rendered when paging occurs). It would probably be helpful if you could post you page's markup.
When you page the grid is rebound and the controls inside it are recreated. To keep the combobox selection, save it Cache of Session object and then recover it from there wiring the PageIndexChanged event of the grid.