You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Milo van der Zee (Created) (JIRA)" <de...@myfaces.apache.org> on 2012/01/02 11:56:30 UTC

[jira] [Created] (MYFACES-3436) render of 'c:' and 'fn:' is one click behind

render of 'c:' and 'fn:' is one click behind
--------------------------------------------

                 Key: MYFACES-3436
                 URL: https://issues.apache.org/jira/browse/MYFACES-3436
             Project: MyFaces Core
          Issue Type: Bug
          Components: General
    Affects Versions: 2.1.5
         Environment: Tomcat 7.0.23, RichFaces 4.1.0-final, MyFaces 2.1.5
            Reporter: Milo van der Zee


'c:' and 'fn:' is rendered differently from previous versions.
When clicking the inc and dec buttons in the example you can see that the field contents are updates each click but the number of fields is not (comma at the end when pressing 'dec'. Pressing 'render' then fixes the output.
When using a function to render it works fine. Even though the function does not do much.

MAG,
Milo

See also: https://issues.jboss.org/browse/RF-11803

{code:title="testje4.xhtml"}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:a4j="http://richfaces.org/a4j"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:rich="http://richfaces.org/rich"
  xmlns:fn="http://java.sun.com/jsp/jstl/functions"
  xmlns:c="http://java.sun.com/jsp/jstl/core"
>

<h:head>
</h:head>

<h:body>
	<h:form>
		<a4j:jsFunction name="render" render="panel,counter" bypassUpdates="true" immediate="true" execute="@none"/>
		
		<h:panelGroup id="counter">
			Counter: #{testBean.counter}<br/>
		</h:panelGroup>
		
		<hr/>
		<h:panelGroup id="panel">
			<c:forEach id="fieldsDefinitions" items="#{testBean.fieldsList}" var="field" varStatus="status">
				<c:set var="fields" value="#{fields}#{field}#{status.last?'':','}"/>
			</c:forEach>
			<c:set var="fieldsArray" value="#{fn:split(fields, ',')}"/>
			<ui:repeat id="repeat" value="#{fieldsArray}" var="field">
				'#{field}', '#{fields}'<br/>
			</ui:repeat>
		</h:panelGroup>
		<hr/>
		
		Direct render:
		<a4j:commandButton value="dec" actionListener="#{testBean.decCounter()}" render="counter, panel"/>
		<a4j:commandButton value="inc" actionListener="#{testBean.incCounter()}" render="counter, panel"/>
		<br/>
		With function to render: 
		<a4j:commandButton value="dec" actionListener="#{testBean.decCounter()}" oncomplete="render();"/>
		<a4j:commandButton value="inc" actionListener="#{testBean.incCounter()}" oncomplete="render();"/>
		<br/>
		Without RichFaces:
		<h:commandButton value="dec" actionListener="#{testBean.decCounter()}" >
			<f:ajax event="click" render="counter panel"/>
		</h:commandButton>
		<h:commandButton value="inc" actionListener="#{testBean.incCounter()}">
			<f:ajax event="click" render="counter panel"/>
		</h:commandButton>
		<br/>
		Manual render:
		<a4j:commandButton value="render" render="counter, panel"/>
	</h:form>
</h:body>

</html>
{code}

{code:title="testBean.java"}
package com.vetmanager.base.test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class TestBean {
	private int counter = 5;

	public List<Integer> getTable() {
		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < counter; i++) {
			Double number = Double.valueOf(Math.random() * 1000);
			list.add(Integer.valueOf(number.intValue()));
		}

		return list;
	}

	public String getFieldsString() {
		StringBuilder builder = new StringBuilder();
		boolean firstField = true;
		for (int i = 0; i < counter; i++) {
			if (!firstField) builder.append(',');
			firstField = false;

			char[] fill = new char[i + 1];
			Arrays.fill(fill, Character.forDigit(counter, 10));
			String fieldName = new String(fill);

			builder.append(fieldName);
		}
		return builder.toString();
	}

	public List<String> getFieldsList() {
		String string = getFieldsString();
		List<String> list = Arrays.asList(string.split(","));
		return list;
	}

	public void decCounter() {
		counter--;
		if (counter < 1) counter = 1;
	}

	public void incCounter() {
		counter++;
		if (counter > 9) counter = 9;
	}

	public int getCounter() {
		return counter;
	}

	public void setCounter(int counter) {
		this.counter = counter;
	}

}
{code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira