[
https://jira.jboss.org/jira/browse/RF-7136?page=com.atlassian.jira.plugin...
]
Denis Petrunin commented on RF-7136:
------------------------------------
There is workaround: reset JSF components values manually. Use
resetUIComponentValueRecursively( String componentId ) where componentId is form id.
/**
* Resets UIInput/UIData components value to un-initialized state. The given
component
* and all childs are affected recursively.
*
* @see <a
href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/...
* @see <a
href="http://java.sun.com/javaee/5/docs/api/javax/faces/component/UI...
value)</a>
*
* @param componentId is an id of root component to reset value of and all childs
recursively, can be null
*/
public static void resetUIComponentValueRecursively( String componentId )
{
if ( componentId != null ) {
UIComponent root =
FacesContext.getCurrentInstance().getViewRoot().findComponent(componentId);
resetUIComponentValueRecursively(root);
}
}
/**
* Resets UIInput/UIData components value to un-initialized state. The given
component
* and all childs are affected recursively.
*
* @see <a
href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/...
* @see <a
href="http://java.sun.com/javaee/5/docs/api/javax/faces/component/UI...
value)</a>
*
* @param component is a root component to reset value of and all childs recursively,
can be null
*/
public static void resetUIComponentValueRecursively( UIComponent component )
{
if ( component != null ) {
resetUIComponentValue(component);
for ( UIComponent child : component.getChildren() )
resetUIComponentValueRecursively(child);
}
}
/**
* Resets UIInput/UIData component value to un-initialized state.
*
* @see <a
href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/javax/...
* @see <a
href="http://java.sun.com/javaee/5/docs/api/javax/faces/component/UI...
value)</a>
*
* @param component to reset value of, can be null
*/
private static void resetUIComponentValue( UIComponent component )
{
if ( component instanceof UIInput ) {
((UIInput) component).resetValue();
} else if ( component instanceof UIData ) {
((UIData) component).setValue(null);
}
}
h:inputText doesn't reflect backing bean value on ajax
rerendering
------------------------------------------------------------------
Key: RF-7136
URL:
https://jira.jboss.org/jira/browse/RF-7136
Project: RichFaces
Issue Type: Bug
Affects Versions: 3.3.0
Environment: RichFaces 3.3.0GA
Mojarra JSF Implementation 1.2_12-b01-FCS
Reporter: Denis Petrunin
Assignee: Tsikhon Kuprevich
1) open edit.jsf page (see below)
2) input "1" into "Id" field, click "Edit" button
3) make a note that "Name" field contains "First", "Note"
field contains "Note-1"
4) clear "Name" field, click "Save" button
5) make a not that the error message is shown: "fmEdit:itName: Validation Error:
Value is required."
6) input "2" into "Id" field, click "Edit" button
7) make a note that "Name" field contains "Second", "Note"
field still contains "Note-1"
Expected result: "Note" field must contain "Note-2"
I think other UIInput, UIData are affected as well.
<<===== edit.jspx =====>>
<?xml version="1.0" encoding="UTF-8"?>
<!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:rich="http://richfaces.org/rich"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:s="http://jboss.com/products/seam/taglib">
<head>
</head>
<body>
<h:form id="fmItemSelector">
<h:outputLabel value="Id" />
<h:inputText value="#{bean.editingItemId}" />
<a4j:commandButton value="Edit" reRender="fmEdit" />
</h:form>
<h:form id="fmEdit">
<h:panelGrid columns="2">
<h:outputLabel value="Name" />
<h:inputText id="itName" value="#{bean.editingItem.name}"
required="true" disabled="#{bean.editingItem == null}" />
<h:outputLabel value="Note" />
<h:inputText id="itNote" value="#{bean.editingItem.note}"
required="true" disabled="#{bean.editingItem == null}" />
</h:panelGrid>
<a4j:commandButton value="Save" rendered="#{bean.editingItem !=
null}" action="#{bean.save}" reRender="fmItemSelector, fmEdit"
/>
</h:form>
<rich:messages />
</body>
</html>
<<===== Backing bean =====>>
import java.util.Arrays;
import java.util.List;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@Name("bean")
@Scope(ScopeType.SESSION)
public class Test
{
private static final List<Item> model = Arrays.asList(new Item(1,
"First", "Note-1"), new Item(2, "Second",
"Note-2"));
private Integer editingItemId;
public Item getEditingItem()
{
if (editingItemId == null)
return null;
for (Item item : model) {
if (item.getId() == editingItemId)
return item;
}
return null;
}
public void save()
{
editingItemId = null;
}
public Integer getEditingItemId()
{
return editingItemId;
}
public void setEditingItemId(Integer editingItemId)
{
this.editingItemId = editingItemId;
}
public static class Item
{
private int id;
private String name;
private String note;
public Item(int id, String name, String note)
{
this.id = id;
this.name = name;
this.note = note;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getNote()
{
return note;
}
public void setNote(String note)
{
this.note = note;
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira