Data Table default sorting not working when forward

UI Components for JSF
Post Reply
shubforall
Posts: 40
Joined: 13 Jan 2012, 09:24

13 Jan 2012, 09:33

Hi,

I am facing issue with data table default sorting when I am forwading request. It works fine when I redirect.

here is my data table code (showBooks.xhtml)

Code: Select all

<p:dataTable id="bookDataTable" sortBy="#{book.price}"  var="book" value="#{shoppingController.books}"
			selection="#{orderController.selectedBook}" rowKey="#{book.id}" widgetVar="shubhamDataTable">

			<f:facet name="header">  
			Select Book(s)
        </f:facet>

			<p:column id="shubhamColumn"  styleClass="shubhamStyle" selectionMode="multiple" />

			<p:column headerText="Name"  >
			  
            #{book.name}
		        
        </p:column>

			<p:column headerText="Author">  
            #{book.author}  
        </p:column>

		<p:column headerText="Price"    >  
            	#{book.price}  
        </p:column>

			<f:facet name="footer">
				<p:commandButton value="Submit" onclick="if(!validate()) return false;"
					actionListener="#{orderController.updateTotal}"
					update=":form:displayMulti" oncomplete="multiBookDialog.show()" />
			</f:facet>
		</p:dataTable>
		 <h:commandLink>  
            Click here to export  
            <p:dataExporter  type="pdf" target="bookDataTable" fileName="books" pageOnly="true"/>  
        </h:commandLink> 

		<p:dialog header="Selected Books" widgetVar="multiBookDialog"
			height="300" showEffect="fade" hideEffect="explode">
			<p:dataTable id="displayMulti" var="book"
				value="#{orderController.selectedBook}">
				<f:facet name="header">  
					Selected Book(s)
             </f:facet>
				<p:column>
					<f:facet name="header">  
                    Name  
            		</f:facet>
					<h:outputText value="#{book.name}" />
				</p:column>

				<p:column>
					<f:facet name="header">  
                    Author  
            		</f:facet>
					<h:outputText value="#{book.author}" />
				</p:column>

				<p:column >
					<f:facet name="header">  
                    Price  
       		    	 </f:facet>
					<h:outputText value="#{book.price}" />
				</p:column>
				<f:facet name="footer">

					<h:outputText value="#{orderController.total}" />
					<h:commandButton value="Confirm" onclick="confirmation.show()"
						type="button" />

				</f:facet>
			</p:dataTable>

Here is my bean code

Code: Select all



@ManagedBean(name = "shoppingController")
public class ShoppingController implements Serializable {

	private List<Book> books;
	private BookDataModel bookDataModel;

	public ShoppingController() {
		ApplicationContext applicationContext = ApplicationContextHelper
				.getApplicationContext();
		bookModal = (BookModal) applicationContext.getBean("bookModal");
		books = bookModal.getBooks();
	
	}

	public List<Book> getBooks() {
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}

}

I am accessing this page after login screen sor in my login page if the login is successfull I am forwarding to this page. In this case default sorting doesn't work but whenevere I redirect or access the above page directly it works.
Please help...
Thanks.

Please note - I have extracted only relevent code.
PrimeFaces 5.2, Websphere liberty profile.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

13 Jan 2012, 09:37

You need to redirect then.

shubforall
Posts: 40
Joined: 13 Jan 2012, 09:24

13 Jan 2012, 10:29

optimus.prime wrote:You need to redirect then.
Ok yeah I mentioned its working when I am redirecting.

Any explaination why it doesn't work in case of forward ?
PrimeFaces 5.2, Websphere liberty profile.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

13 Jan 2012, 10:44

isPostBack in JSF returns true for forwards.

shubforall
Posts: 40
Joined: 13 Jan 2012, 09:24

13 Jan 2012, 10:49

optimus.prime wrote:isPostBack in JSF returns true for forwards.
ohho yeah yaeah... Thanks Optimus :D
PrimeFaces 5.2, Websphere liberty profile.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

13 Jan 2012, 11:31

Forward sucks anyway :) POST-REDIRECT-GET

shubforall
Posts: 40
Joined: 13 Jan 2012, 09:24

13 Jan 2012, 12:08

optimus.prime wrote:Forward sucks anyway :) POST-REDIRECT-GET
Thats correct.
PrimeFaces 5.2, Websphere liberty profile.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 45 guests