I am working for navigation from Table View to View Controller, when I am clicking row I got exception as System.NullReferenceException has been thrown Object reference not set to an instance of an object
Here is code:
UITableViewController _contact;
public Contactlist(UITableViewController contact)
{
_contact=contact;
}
public override void Row Selected (UITableView tableView, NSIndexPath indexPath)
{
// Error System.NullReferenceException
_contact.NavigationController.PushViewController(new incomingscreen(),true);
}
please help
A ViewController's NavigationController property will be null unless the ViewController is contained within a NavigationController.
window.RootViewController = new UINavigationController(new MyTableViewController());
Related
I need to create a custom component that either extend or include a Primefaces SelectOneMenu. This is done so that I can deliver the select items based on the field (for now, they are hardcoded in the example below and the tag is properly registered).
The component is rendered and the select items are also displayed fine. However, when I save, the record's field is not updated with the selected item's value. Is there some primeface method I should override to actually set the value?
Are there any tutorials on how to extend primeface (or atleast jsf) components? I could hardly find any. Thank you in advance
#FacesComponent(value = ComponentRegistry.INPUT_SELECTDROPDOWN_COMPONENT_TYPE)
public class InputSelectDropdown extends SelectOneMenu {
#Override
public void encodeBegin(FacesContext context) throws IOException {
this.setValueExpression("value", this.getValueExpression("value"));
UISelectItem select1 = new UISelectItem();
select1.setItemLabel("item 1");
select1.setItemValue("item1");
select1.encodeAll(context);
this.getChildren().add(select1);
UISelectItem select2 = new UISelectItem();
select2.setItemLabel("item 2");
select2.setItemValue("item2");
select2.encodeAll(context);
this.getChildren().add(select2);
super.encodeBegin(context);
}
}
I am working for navigation from Table View to View Controller, when I am clicking row I got exception as System.NullReferenceException has been thrown Object reference not set to an instance of an object in xamarin.ios
public override void Row Selected (UITableView tableView, NSIndexPath indexPath)
{
// Error System.NullReferenceException
_contact.NavigationController.PushViewController(new incomingscreen(),true);
}
I have a UITableView and on RowSelected i want to show a loading animation and then load another ViewController:
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
LoadingView LV = new LoadingView();
LV.Show("Loading...");
specScreen = new SpecScreen();
controller.NavigationController.PushViewController(specScreen, true);
LV.Hide();
}
However the loading animation only appears for a split second AFTER the next viewcontroller has loaded.
How do I show the Loading animation and then wait for the next view controller to load and hide it again?
Tanis,
make LoadingView singleton and place LoadingView.Instance.Hide(); to ViewDidAppear in SpecScreen viewcontroller.
I am currently using the advanced editing tableview as outlined in Monotouch.Dialog that allows a user to delete as well as edit the label of table elements. Is there a way to enrich the tableview to achieve something similar to the screenshot, i.e. change the ordering?
You need to add this two methods to your DialogViewController.Source
public override bool CanMoveRow (UITableView tableView, NSIndexPath indexPath)
{
return true;
}
public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
{
tableView.MoveRow(sourceIndexPath,destinationIndexPath);
}
I tried simply:
public class UIDemoComponent extends UIComponentBase {
private String someVariable; // this gets always cleared, getters/setters omitted
public UIDemoComponent() {
super(); // place breakpoint here
}
#Override
public void encodeBegin(FacesContext context) throws IOException {
HtmlForm form = new HtmlForm();
form.setStyle("padding: 10px; background-color: blue;");
getChildren().add(form);
AjaxBehavior behavior = new AjaxBehavior();
behavior.setRender(Arrays.asList("#form"));
form.addClientBehavior("click", behavior);
}
}
I have registered a tag handler and succesfully inserted the component into page. However, when I click the blue form that is rendered, JSF re-creates the component (breakpoint in the constructor is caught). The effect of this is that any instance variables are lost. How is one supposed to save data into components if they always get re-created?
I tried overriding and inspecting the state staving mechanisms of StateHolder and PartialStateHolder wihout luck:
#Override
public Object saveState(FacesContext context) {
return super.saveState(context); // breakpoint
}
#Override
public void restoreState(FacesContext context, Object state) {
super.restoreState(context, state); // breakpoint
}
JSF is executing the saveState when page and components are created, but restoreState is never called. Actually, when the AJAX request is being processed, a new instamnce of UIDemoComponent is created but saveState method is called again, instead of restoreState.
How to create such a state-saving component (that retains the instance fields over AJAX requests)?
Seems like JSF is running some pre-checks on state object and not executing restoreState at all if custom fields are not entered. Only after actually inserting custom values into state object, the restoreState gets called.
For example:
#Override
public Object saveState(FacesContext context) {
Object[] rtrn = new Object[2];
rtrn[0] = super.saveState(context);
rtrn[1] = "dummy";
return rtrn;
}
After this, the restoreState gets called and property fields can be restored as wanted.