DataTable: OnRowSelectUpdate Doesn't Work in Safari

UI Components for JSF
Post Reply
davecurryco
Posts: 19
Joined: 12 Nov 2010, 21:45

18 Nov 2010, 06:53

I am using Primefaces 2.2RC1 with Mojarra 2.0.3 on Tomcat 6.0.29 and JBoss 4.2.2. I have a simple DataTable on a Facelets page that uses a single row select to update another panel in the same Form on the same page using the Instant Select feature. This works fine in Firefox 3.6 and IE 8.0, but in Safari 5.0 and Chrome 7.0, the target panel never gets updated. In fact, the newly selected row highlights and the previously selected row stays highlighted as well.

I have a complete example program that I can post if need be, but here's the relevant code:

Facelets View: fruitSales.xhtml

Code: Select all

<h:form>
	<p:dataTable value="${salesTotalBean.quarterTotals}" var="quarterTotal"
		selection="#{salesTotalBean.selectedQuarterTotal}" selectionMode="single"
		onRowSelectUpdate="salesInfoPanel"
		onRowUnselectUpdate="salesInfoPanel">
		<p:column>
			<f:facet name="header">Year</f:facet>
			<h:outputText value="${quarterTotal.year}"/>
		</p:column>
		<p:column>
			<f:facet name="header">Quarter</f:facet>
			<h:outputText value="${quarterTotal.quarter}"/>
		</p:column>
		<p:column>
			<f:facet name="header">Unit Sales</f:facet>
			<h:outputText value="${quarterTotal.total}"/>
		</p:column>
	</p:dataTable>
	<p:outputPanel id="salesInfoPanel">
		<p:panel id="salesQuarterTotalPanel">
			<h:panelGroup rendered="${!(empty salesInfoBean.selectedQuarterTotal)}">
				${salesInfoBean.selectedQuarterTotal.year} Q${salesInfoBean.selectedQuarterTotal.quarter}
			</h:panelGroup>
			<h:panelGroup rendered="${(empty salesInfoBean.selectedQuarterTotal)}">
				No quarter selected
			</h:panelGroup>
		</p:panel>
	</p:outputPanel>
</h:form>
Backing Bean: SalesTotalBean.java

Code: Select all

@ManagedBean
@ViewScoped
public class SalesTotalBean implements Serializable {
	private static final long serialVersionUID = 1L;

	@ManagedProperty(value="#{salesService}")
	private SalesService salesService;
	
	private ArrayList<SalesQuarterTotal> quarterTotals;
	private SalesQuarterTotal selectedQuarterTotal;

	@PostConstruct
	public void postConstruct() {
		quarterTotals = salesService.listQuarterlySalesTotals();
	}
	
// Getters and setters	
}
BackingBean: SalesInfoBean.java

Code: Select all

@ManagedBean
@RequestScoped
public class SalesInfoBean {
	@ManagedProperty(value="#{salesProductBean}")
	private SalesProductBean salesProductBean;
	@ManagedProperty(value="#{salesTotalBean}")
	private SalesTotalBean salesTotalBean;

	@PostConstruct
	public void postConstruct() {
		SalesQuarterTotal selectedQuarter = salesTotalBean.getSelectedQuarterTotal();
		SalesQuarterTotal productQuarter = salesProductBean.getSelectedQuarterTotal();
		
		if (selectedQuarter != null && (productQuarter == null || !selectedQuarter.equals(productQuarter))) {
			salesProductBean.setSelectedQuarterTotal(selectedQuarter);
			salesProductBean.doUpdate();
		}
	}
	
// Getters and setters
	
}
Acting on a work-around in a similar issue on this forum, I added the following tag to the Facelets view:

Code: Select all

<f:view content-type="text/html">
I've also tried changing the SalesTotalBean to SessionScoped and specifying a complete set of event listeners and update attributes:

Code: Select all

	<p:dataTable value="${salesTotalBean.quarterTotals}" var="quarterTotal"
		selection="#{salesTotalBean.selectedQuarterTotal}" selectionMode="single"
		rowSelectListener="#{salesTotalBean.onRowSelect}"
		onRowSelectUpdate="salesInfoPanel"
		rowUnselectListener="#{salesTotalBean.onRowUnselect}"
		onRowUnselectUpdate="salesInfoPanel">
Neither of these approaches helped. This is a little baffling because the Instant Selection example in the ShowCase works with Safari and Chrome. Clues anyone?

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

18 Nov 2010, 15:41

Instead of:

Code: Select all

<f:view content-type=...
It should be:

Code: Select all

<f:view contentType=...

sgauge
Posts: 7
Joined: 16 Sep 2010, 13:39

18 Nov 2010, 15:51

Hey, I've had the exact same issue, with Chrome.

First of all, switching back to 2.2M1 solved the problem.

I tried many things, including searching for modifications into datatable.js prior to posting a bug report.

I finally switched my library back again to 2.2RC1, restarted Netbeans, cleaned and rebuilt the project, and it seems to work fine now. I'll post here later if the problem arises again.
Primefaces 2.2RC1
Glassfish 3.0.1
Mojarra 2.0.2

Veit
Posts: 14
Joined: 20 Jul 2010, 15:00

18 Nov 2010, 17:39

I have the same problem with RC1/RC2.

Strange behaviour: It works in my local test server on windows 7 ( GlassFish v3 (build 74.2)) but not in the linux production server (GlassFish Server Open Source Edition 3.0.1 (build 22)).

davecurryco
Posts: 19
Joined: 12 Nov 2010, 21:45

18 Nov 2010, 20:59

Thanks for the replies. As suggested, I did a clean on my project, the deployed WAR and the Tomcat working directory. I also reset Safari. I then modified the page to include the following declaration:

Code: Select all

<f:view contentType="text/html">
This worked! To verify, I removed the f:view tag, cleaned everything again and re-tested. The problem re-appeared. I then put the f:view line back in and the problem went away. I tested with Chrome and it worked too.

One thing that concerns me is that contentType does not seem to be a documented attribute of f:view (thus the "content-type" mistake). It's not in any of my references for JSF 2.0, nor does it appear in the tag documentation for Mojarra 2.0.3:

https://javaserverfaces.dev.java.net/no ... /view.html

Anyway, I'm cooking again. Thanks for the help!

Veit
Posts: 14
Joined: 20 Jul 2010, 15:00

19 Nov 2010, 14:59

I come closer... it's not the WebServer or the OS...it's Eclipse. When I publish the Project internalle via Eclipse...everything is fine. But when I try to Export the Projekt to a WAR-File something goes wrong with RC2.1/2.2.

Veit
Posts: 14
Joined: 20 Jul 2010, 15:00

19 Nov 2010, 15:42

It's a pitty. There is also a issue with special characters in the the table. For example if a list in a bean which displays the Rows has some german characters like ü or ä nothing is displayed.

The last Version where everythings runs fine is 2.2M1-Snapshot. 2.2M1, RC1 and RC2 does not. I really liked PrimeFaces...but 2.2 pushing me down.

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

19 Nov 2010, 17:36

Try a character encoding filter.

Strider
Posts: 70
Joined: 03 Dec 2009, 22:24

19 Nov 2010, 17:44

Yes, i use a character encoding filter in all projects which using german language.

Code: Select all

@WebFilter
public class CharacterEncodingFilter implements Filter
{

	@Override
	public void doFilter( ServletRequest req, ServletResponse resp, FilterChain chain ) throws IOException,
			ServletException
	{
		req.setCharacterEncoding( "UTF-8" );
		resp.setCharacterEncoding( "UTF-8" );
		chain.doFilter( req, resp );
	}


	@Override
	public void init( FilterConfig filterConfig ) throws ServletException
	{
	}


	@Override
	public void destroy()
	{
	}


}

Veit
Posts: 14
Joined: 20 Jul 2010, 15:00

19 Nov 2010, 21:51

YEAH!

That was it. Madly it also solved my click problem. Thanks a lot for your help :).

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests