@Override public Page onRuntimeException(Page page, RuntimeException e) { if(e instanceof InvalidUrlException) { return new HomePage(); } else { return super.onRuntimeException(page, e); } }
@Override public HomePage map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { HomePage homePage = new HomePage(); homePage.setId((UUID) resultSet.getObject("id")); if (!Strings.isNullOrEmpty(resultSet.getString("localization_data"))) { ObjectMapper mapper = new ObjectMapper(); try { Map<Locale, Map<String, Object>> localizedVersions = Maps.newHashMap(); Map[] data = mapper.readValue(resultSet.getString("localization_data"), Map[].class); for (Map map : data) { localizedVersions.put(LocaleUtils.toLocale((String) map.get("locale")), (Map) map.get("entity")); } homePage.setLocalizedVersions(localizedVersions); } catch (IOException e) { throw new SQLException("Failed to de-serialize localization JSON data", e); } } return homePage; } }
public HomePage create(@Valid HomePage homePage) throws EntityAlreadyExistsException, InvalidEntityException { if (this.dao.findBySlug(HOME_PAGE_TYPE, homePage.getSlug(), getTenant()) != null) { throw new EntityAlreadyExistsException(); } this.dao.begin(); UUID entityId = UUID.randomUUID(); homePage.setId(entityId); this.dao.createEntity(homePage, HOME_PAGE_TYPE, getTenant()); this.dao.createOrUpdateAddons(homePage); this.dao.commit(); return homePage; }
public void update(@Valid HomePage entity) throws EntityDoesNotExistException, InvalidEntityException { this.dao.begin(); HomePage homePage = find(); if (homePage == null) { this.dao.commit(); throw new EntityDoesNotExistException(); } getObservationManager().notify(new EntityUpdatingEvent(), entity); entity.setId(homePage.getId()); this.dao.createOrUpdateAddons(entity); this.dao.commit(); getObservationManager().notify(new EntityUpdatedEvent(), entity); }
private HomePage find() { HomePage page = this.dao.find(getTenant()); if (page != null) { List<AddonGroup> addons = this.dao.findAddons(page); page.setAddons(asMap(addons)); } return page; }
public HomePage getOrCreate(HomePage homePage) throws InvalidEntityException { HomePage original; this.dao.begin(); original = this.find(); if (original != null) { this.dao.commit(); return original; } getObservationManager().notify(new EntityCreatingEvent(), homePage); UUID entityId = UUID.randomUUID(); homePage.setId(entityId); this.dao.createEntityIfItDoesNotExist(homePage, HOME_PAGE_TYPE, getTenant()); this.dao.commit(); getObservationManager().notify(new EntityCreatedEvent(), homePage); return this.find(); }
JPanel homepage = new HomePage(...); cardPanel.add(...);
public class LoginPage { public HomePage loginAs(String username, String password) { WebElement username = driver.findElement(By.id("user")); username.sendKeys("admin"); WebElement password = driver.findElement(By.id("pass")); password.sendKeys("admin"); WebElement login = driver.findElement(By.id("login")); login.click(); return new HomePage(); }
System.out.println("Pos 1 "); (new HomePage()).LogIn();
Fragment fragment = null; switch (position) { case 0: fragment = new HomePage(); break; case 1: fragment = new SecondPage(); break; case 2: fragment = new ThirdPage(); break; case 3: fragment = new SettingsPage(); break; default: break; } if (fragment != null) { FragmentManager fm = getSupportFragmentManager(); FragmentTransaction transaction = fm.beginTransaction().replace(R.id.frame_container, fragment); transaction.commit();
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() { // This method will trigger on item Click of navigation menu @Override public boolean onNavigationItemSelected(MenuItem menuItem) { //Checking if the item is in checked state or not, if not make it in checked state if (menuItem.isChecked()) menuItem.setChecked(false); else menuItem.setChecked(true); //Closing drawer on item click drawerLayout.closeDrawers(); //Check to see which item was being clicked and perform appropriate action switch (menuItem.getItemId()) { //Replacing the main content with ContentFragment Which is our Inbox View; case R.id.drawer_how: FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction(); fragmentTransaction.replace(R.id.framelayout, new HomePage()); fragmentTransaction.commit(); return true; // For rest of the options we just show a toast on click ..... default: Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show(); return true; } } });
var AppRouter = Backbone.Router.extend({ routes: { '*otherwise': 'homepage', 'specific/:id': 'specificPage' }, initialize: function() { this.layout = new Layout(); this.layout.render(); this.views = {}; }, homepage: function() { // These local variables improve minification and readability. var views = this.views, homepage = views.homepage; if (!homepage) { views.homepage = homepage = new HomePage(); } this.layout.setContent(homepage); }, specificPage: function(id){ var views = this.views, specific = views.specific; if (!specific){ views.specific = specific = new HomePage(); } specific.setId(id); // hypothetical logic this.layout.setContent(specific); } });
switch (position) { case 0: f = new HomePage(); fragments[position] = f; break;
case 0 : return new HomePage(); case 1 : return new Attendence(); case 2 : return new Delivery();