You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by SEIDLER DANIEL <da...@gmail.com> on 2007/12/13 15:48:58 UTC
Idea for Cancel in Form with Ajax needed
Hi,
i have this code:
<h:form id="form">
<h:outputText rendered="#{!bean.editable}" value="#{bean.firstName}" />
<br />
<h:outputText rendered="#{!bean.editable}" value="#{bean.lastName}" />
<h:inputText rendered="#{bean.editable}" value="#{bean.firstName}"
id="firstName"/>
<h:inputText rendered="#{bean.editable}" value="#{bean.lastName}"
id="firstName"/>
<t:div rendered="#{bean.owner && !bean.editable}">
<a4j:commandLink action="#{bean.edit}" reRender="form" value="Edit"
id="editButton" ajaxSingle="true"
onclick="if (!isEditable()) {alert('#{msg
['warnings.edit']}');return false};" oncomplete="setEditable(false);" />
</t:div>
<t:div rendered="#{bean.owner && ben.editable}">
<a4j:commandLink value="Save" id="saveButton" action="#
{bean.save}" reRender="form"
oncomplete="setEditable(true);" />
<a4j:commandLink value="Cancel" id="cancelButton" action="#
{bean.cancel}" reRender="form"
immediate="true" oncomplete="setEditable(true);" />
</t:div>
</h:form>
This Form has two States Editable and Not Editable. I can Edit and
Save this Form , but I have no idea how to realize a Cancel Link. At
the moment, if i click cancel, the Output is like it should, the old
value(also before editing). But if I click edit again, in the
InputField is the value what I entered before click cancel. Any
Ideas, what i can put in my bean? I tried to get the Data from
Database and overwrite the InputFields, but then I get errors,
because I'm using Lazyinitialization.
I think the problem is A4J, because I havent the full request, my
Input Field is still filled with old values.
Like you see in my Code Im using A4J. And also Myfaces 1.1.5 with
Tomahawk 1.1.6
Thx. i. A.