You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by ag...@custis.ru on 2006/07/10 15:38:47 UTC
another Cancel button question
Hello.
Stupid situation.
dataTable, row on click -> show Edit Form that have one field and 2
buttons (Save and Cancel). Also i have newItem_button, which show the
same form.
Problem with Cancel. I emulate problem with such bit of code (without dataTable):
page:
<h:form id="foo">
<h:commandButton id="new" type="submit" value="Add New" actionListener="#{testBean1.newUser}"/>
<h:commandButton id="show" type="submit" value="Show Existed" actionListener="#{testBean1.showUser}"/>
<t:panelGrid columns="2" rendered="#{testBean1.user!=null}">
<h:outputLabel for="id">
<h:outputText value="Id:"/><h:outputText value="*" style="color:red"/>
</h:outputLabel>
<h:inputText id="id" size="32" value="#{testBean1.user.id}" required="true">
<f:validateLength maximum="32"/>
</h:inputText>
<h:commandButton id="backCmd1" type="submit" value="Back1" actionListener="#{testBean1.backActionLsnr}"
rendered="#{testBean1.user.id != null}"
onclick="if (document.getElementById('foo').reset()) return true;"/>
<h:commandButton id="backCmd2" type="submit" value="Back2" action="#{testBean1.backAction}"
rendered="#{testBean1.user.id == null}" immediate="true"/>
</t:panelGrid>
</h:form>
Bean:
public TestBean1 {
private User user = null;
public void backActionLsnr(ActionEvent e) {
user = null;
}
public String backAction() {
user = null;
return null;
}
public void showUser(ActionEvent e) {
user = new User();
user.setId(new Long(10));
}
public void newUser(ActionEvent e) {
user = new User();
}
class User {
private Long id;
public User() {}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
}
i have 2 buttons - createNew && showExisted.
When I click showExisted the input field is appeared with value=10.
i click Back1. It set "user = null" and hide field.
When i click createNew the input field is appeared with value=null.
i click Back2, it skip id validation, set "user = null" and hide field.
All is fine.
Now i click ShowExisted again and i see *empty field* and button Back1.
Trying to click Back1. validation failed and form freezed (i can do
nothing with it).
myfaces 1.1.1
So, i have 2 question
1. where is my fault?
2. may be there is another solution for this task?
It looks like a bug
Posted by GAAA <ag...@custis.ru>.
<h:inputText render incorrect value...
after pressing "ShowExisted" button we get -
HtmlTextRendererBase.renderInput(...) {
...
String value = RendererUtils.getStringValue(facesContext, component);
...
writer.writeAttribute(HTML.VALUE_ATTR, value, JSFAttr.VALUE_ATTR);
...
}
RendererUtils.getStringValue(...) {
..
if (submittedValue != null) {
if (submittedValue instanceof String) return (String)submittedValue;
else throw something;
}
..
}
yes, submittedValue = "", it is not null and it is instance of String... but
component.getValue = Long(10).
--
View this message in context: http://www.nabble.com/another-Cancel-button-question-tf1918501.html#a5253241
Sent from the MyFaces - Users forum at Nabble.com.