Sunday, 15 March 2015

jsf - How to navigate using <p:ajax listener> -


I am trying to set up a way that when a user selects a line, the second page loads The line returns page. EDIT_ITEM is executed but nothing happens, no exceptions or errors, not at all. By typing the URL I can also access Pages.EDIT_ITEM in the browser, but in some way, the backing beam does not work when opening the page.

My figure:

  & lt; P: dataTable id = "categoriesTable" value = "# {category.items}" var = "item" selectionMode = "single" row = "# {item.id}" & gt; & Lt; P: Command Button id = "toggler" type = "button" value = "column" style = "float: right" /> & Lt; P: ajax event = "select row" listener = "# {list categories categories.onRowDblClick}" /> & Lt; P: columnToggler data source = "categoriestable" trigger = "toggleer" /> & Lt; P: column headerText = "# {msg ['addItem.internal_id']}" sortBy = "# {item.internalId}" filterby = "# {item.internalId}" filtermachmode = "contains" & gt; & Lt; H: output text value = "# {item.internalId}" /> & Lt; / P: column & gt; & Lt; / P: DataTable & gt;  

My backing bean:

  package de.rcwgmbh.inventory.controller; Import de.rcwgmbh.inventory.data.CategoryProducer; Import de.rcwgmbh.inventory.data.ItemProducer; Import de.rcwgmbh.inventory.model.Category; Import de.rcwgmbh.inventory.model.Item; Import de.rcwgmbh.inventory.services.ItemService; Import Java.io.Serializable; Import java.util.list; Import java.util.ResourceBundle; Import javax.faces.application.FacesMessage; Import javax.faces.context.FacesContext; Import javax.faces.view.ViewScoped; Import javax.inject.Inject; Import javax.inject.Named; Import javax.preistence.EntityManager; Import org.primefaces.event.SelectEvent; Import org.primefaces.event.TabChangeEvent; Import org.primefaces.event.UnselectEvent; / ** * * @ Author Jelexkis * / @VisionSpods @complete public category list applies segment controller Serializable {Private stationary last long serial UID = -2347239478324 L; Remove the private unit unit manager; Remove the @ Private Category Manufacturer Category Manufacturer; @ Personal ItemService Items Cutting Services; @ Remove personal items Manufacturer items Manufacturer; Public listing & lt; Items & gt; DoListItems (category category) {Final list & amp; Lt; Items & gt; Item = item service .gate item (category); Category.setItems (item); CategoryProducer.setSelectedCategory (category); Return the goods; } Public string doAddCategory () {categoryProducer.prepareAddCategory (); Pages LIST_CATEGORIES; } Public string doEditCategory (category category) {categoryProducer.prepareEditCategory (category); Pages LIST_CATEGORIES; } Public string doEditItem () {itemProducer.prepareEditItem (itemProducer.getSelectedItem ()); Return page EDIT_ITEM; } Public Zero on Tab Change (Tab Change Event Event) {String category name = event.getTab (). GetTitle (); Category category = entityManager.find (category, category, category name); CategoryProducer.setSelectedCategory (category); Resource Bundle Bundle = ResourceBundle.getBundle ("Message", FacesContext.getCurrentInstance (). GetViewRoot (). GetLocale ()); String value = bundle.gate string ("list categories. Category_scheduled"); FacesMessage msg = New FacesMessage (value, event.getTab (.) GetTitle ()); FacesContext.getCurrentInstance (). AddMessage (null, msg); } Public Payment onRowDblClick (SelectEvent Event) {itemProducer.setSelectedItem (item) event.getObject ()); DoEditItem (); }}  

You do not have a redirect in this code.
Ajax listener calls are not the same as action s command button s, if you do not return the string then just nothing will happen.
If you want to redirect to another page, you can do so in your AJAX call: FacesContext.getCurrentInstance (). GetExternalContext (). Redirect ("Other Pages. XHTML"); .


No comments:

Post a Comment