You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "R. Müller" <r....@unicomp-berlin.de> on 2005/12/05 16:05:31 UTC
editable forms
hi group,
in a particular form i want the fields only editable, if there is
explicitly set a edit-param.
I've tried it with the following code :
<h:outputText rendered="#{empty param.edit}"
value="#{backingBean.value}/>
<h:selectOneMenu rendered="#{!empty param.edit}"
value="#{backingBean.value}">
<f:selectItems value="#{selectItems}" />
</h:selectOneMenu>
But i've noticed that when submitting the form the 'setter'-method of
the 'backingBean.value' is never called.
Leaving out the 'rendering'-attribute, which means that the component is
always editable everthing works fine.
I've got the same behaviour when using the 'disabled'-attribute.
Does anybody has an explanation for this or hints how to solve this in a
'clean way' ?
thanx
ronald
--
*********************************************************
*M-Unicomp GmbH
*
*Ronald Müller
*
*Plauener Straße 163-165, Haus 11
*13053 Berlin
*
*fon : +49 ( 0 ) 30 / 98 69 61 54
*mobil : +49 ( 0 ) 172 / 93 95 00 4
*fax : +49 ( 0 ) 30 / 98 69 61 55
*email : r.mueller@unicomp-berlin.de
*web : www.unicomp-berlin.de
********************************************************
Re: editable forms
Posted by "R. Müller" <r....@unicomp-berlin.de>.
hi,
Mike Kienenberger wrote:
> The problem is that #{param.edit} doesn't maintain a constant value.
> The component's "rendered" attribute value must be the same between
> the first and second request. If it's rendered on the initial
> request, but not rendered on the submitting request, then the backing
> bean won't be updated (the value won't even be validated).
> Components are only evaluated (decoded, converted, validated, copied
> to backing beans, rendered) if the rendered attribute is true.
thank you, i think thats exactly the problem.
the thing is, i'm trying to do as much as possible without changes in my
JAVA-code.
i think this problem is also a very common usecase for forms. Much forms
have the possibility to check the inputs on a second page without the
ability to change them (wizards). basically this must be possible with
same form - just other renderers for the values !?
is there another approach for doing this.
regards ronald
--
*********************************************************
*M-Unicomp GmbH
*
*Ronald Müller
*
*Plauener Straße 163-165, Haus 11
*13053 Berlin
*
*fon : +49 ( 0 ) 30 / 98 69 61 54
*mobil : +49 ( 0 ) 172 / 93 95 00 4
*fax : +49 ( 0 ) 30 / 98 69 61 55
*email : r.mueller@unicomp-berlin.de
*web : www.unicomp-berlin.de
********************************************************
Re: editable forms
Posted by Mike Kienenberger <mk...@gmail.com>.
The problem is that #{param.edit} doesn't maintain a constant value.
The component's "rendered" attribute value must be the same between
the first and second request. If it's rendered on the initial
request, but not rendered on the submitting request, then the backing
bean won't be updated (the value won't even be validated).
Components are only evaluated (decoded, converted, validated, copied
to backing beans, rendered) if the rendered attribute is true.
On 12/5/05, "R. Müller" <r....@unicomp-berlin.de> wrote:
> hi group,
>
> in a particular form i want the fields only editable, if there is
> explicitly set a edit-param.
>
> I've tried it with the following code :
>
> <h:outputText rendered="#{empty param.edit}"
> value="#{backingBean.value}/>
> <h:selectOneMenu rendered="#{!empty param.edit}"
> value="#{backingBean.value}">
> <f:selectItems value="#{selectItems}" />
> </h:selectOneMenu>
>
> But i've noticed that when submitting the form the 'setter'-method of
> the 'backingBean.value' is never called.
> Leaving out the 'rendering'-attribute, which means that the component is
> always editable everthing works fine.
> I've got the same behaviour when using the 'disabled'-attribute.
>
> Does anybody has an explanation for this or hints how to solve this in a
> 'clean way' ?
>
> thanx
>
>
> ronald
> --
> *********************************************************
> *M-Unicomp GmbH
> *
> *Ronald Müller
> *
> *Plauener Straße 163-165, Haus 11
> *13053 Berlin
> *
> *fon : +49 ( 0 ) 30 / 98 69 61 54
> *mobil : +49 ( 0 ) 172 / 93 95 00 4
> *fax : +49 ( 0 ) 30 / 98 69 61 55
> *email : r.mueller@unicomp-berlin.de
> *web : www.unicomp-berlin.de
> ********************************************************
>
Re: editable forms
Posted by "R. Müller" <r....@unicomp-berlin.de>.
Thank you.
I think i will try a similiar approach.
Regards Ronald
Yee CN wrote:
> What I did is that I maintain an enum called screenMode={VIEW,EDIT,ADDNEW}
> in the backing bean.
>
> public boolean isEditMode() {
> return this.screenMode == ScreenMode.EDIT || this.screenMode
> == ScreenMode.ADDNEW;
> }
>
> public boolean isAddnewMode() {
> return this.screenMode == ScreenMode.ADDNEW;
> //return this.addNew;
> }
>
> /**
> * Getting/Setting the ScreenMode Enum as String
> * @return String
> */
> public String getScreenMode() {
> return this.screenMode.toString() ;
> }
>
> public void setScreenMode(String mode) {
> this.screenMode = ScreenMode.valueOf(mode) ;
> }
>
>
> In your jsf file you will do:
> <t:saveState value=”#{myBean.screenMode}” />
> <h:selectOneMenu rendered="#{!myBean.editMode}"
>
>
> Hope this help.
>
> Regards,
> Yee
>
> -----Original Message-----
> From: "R. Müller" [mailto:r.mueller@unicomp-berlin.de]
> Sent: Monday, 5 December 2005 11:06 PM
> To: users@myfaces.apache.org
> Subject: editable forms
>
> hi group,
>
> in a particular form i want the fields only editable, if there is
> explicitly set a edit-param.
>
> I've tried it with the following code :
>
> <h:outputText rendered="#{empty param.edit}"
>
> value="#{backingBean.value}/>
> <h:selectOneMenu rendered="#{!empty param.edit}"
>
> value="#{backingBean.value}">
> <f:selectItems value="#{selectItems}" />
> </h:selectOneMenu>
>
> But i've noticed that when submitting the form the 'setter'-method of
> the 'backingBean.value' is never called.
> Leaving out the 'rendering'-attribute, which means that the component is
> always editable everthing works fine.
> I've got the same behaviour when using the 'disabled'-attribute.
>
> Does anybody has an explanation for this or hints how to solve this in a
> 'clean way' ?
>
> thanx
>
>
> ronald
--
*********************************************************
*M-Unicomp GmbH
*
*Ronald Müller
*
*Plauener Straße 163-165, Haus 11
*13053 Berlin
*
*fon : +49 ( 0 ) 30 / 98 69 61 54
*mobil : +49 ( 0 ) 172 / 93 95 00 4
*fax : +49 ( 0 ) 30 / 98 69 61 55
*email : r.mueller@unicomp-berlin.de
*web : www.unicomp-berlin.de
********************************************************
RE: editable forms
Posted by Yee CN <ye...@streamyx.com>.
What I did is that I maintain an enum called screenMode={VIEW,EDIT,ADDNEW}
in the backing bean.
public boolean isEditMode() {
return this.screenMode == ScreenMode.EDIT || this.screenMode
== ScreenMode.ADDNEW;
}
public boolean isAddnewMode() {
return this.screenMode == ScreenMode.ADDNEW;
//return this.addNew;
}
/**
* Getting/Setting the ScreenMode Enum as String
* @return String
*/
public String getScreenMode() {
return this.screenMode.toString() ;
}
public void setScreenMode(String mode) {
this.screenMode = ScreenMode.valueOf(mode) ;
}
In your jsf file you will do:
<t:saveState value=#{myBean.screenMode} />
<h:selectOneMenu rendered="#{!myBean.editMode}"
Hope this help.
Regards,
Yee
-----Original Message-----
From: "R. Müller" [mailto:r.mueller@unicomp-berlin.de]
Sent: Monday, 5 December 2005 11:06 PM
To: users@myfaces.apache.org
Subject: editable forms
hi group,
in a particular form i want the fields only editable, if there is
explicitly set a edit-param.
I've tried it with the following code :
<h:outputText rendered="#{empty param.edit}"
value="#{backingBean.value}/>
<h:selectOneMenu rendered="#{!empty param.edit}"
value="#{backingBean.value}">
<f:selectItems value="#{selectItems}" />
</h:selectOneMenu>
But i've noticed that when submitting the form the 'setter'-method of
the 'backingBean.value' is never called.
Leaving out the 'rendering'-attribute, which means that the component is
always editable everthing works fine.
I've got the same behaviour when using the 'disabled'-attribute.
Does anybody has an explanation for this or hints how to solve this in a
'clean way' ?
thanx
ronald
--
*********************************************************
*M-Unicomp GmbH
*
*Ronald Müller
*
*Plauener Straße 163-165, Haus 11
*13053 Berlin
*
*fon : +49 ( 0 ) 30 / 98 69 61 54
*mobil : +49 ( 0 ) 172 / 93 95 00 4
*fax : +49 ( 0 ) 30 / 98 69 61 55
*email : r.mueller@unicomp-berlin.de
*web : www.unicomp-berlin.de
********************************************************