You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by bansi <ma...@yahoo.com> on 2008/04/19 19:52:33 UTC
JSF Value-Binding to Model Object doesnt work
Here is the code sample
<html>
<body>
<f:view>
<h:form id="updateDeviceForm">
<h:panelGrid>
..........
..........
<h:inputText id="deviceName" value="#{deviceBean.name}" style="width: 230px"
styleClass="required max-63" >
</h:panelGrid>
<h:panelGrid>
<ui:include src="fqdnForm.xhtml"></ui:include>
</h:panelGrid>
</f:view>
</body>
</html>
Here is the snippet of fqdnForm.xhmtl which has value binding of name form
field to model object Fqdn
<body>
<h:panelGrid columns="3" styleClass="detail" columnClasses="label">
<h:inputText id="hostName" value="#{fqdnBean.fqdn. name}" style="width:
230px"
styleClass="required max-63" >
</h:inputText>
<h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
converter="#{fqdnConverter}"></h:inputHidden>
</h:panelGrid>
</body>
The problem is i am unable to access model object fqdn in deviceBean and
ofcourse quite obviously i am able to successfully access Fqdn model object
in FqdnBean.
But as fqdnForm is included in deviceForm i am accessing Fqdn model object
or FqdnBean in deviceBean as follows and it returns NULL
1)
FqdnBean fqdnBean = (FqdnBean)
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
"fqdnHidden");
Any pointers/suggestions will be highly appreciated
--
View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16785936.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF Value-Binding to Model Object doesnt work
Posted by Oliver Becker <ob...@obqo.de>.
>
> I also tried injecting FqdnBean into DeviceBean and then access
> model object
> of FqdnBean i.e. Fqdn into DeviceBean as
> Fqdn fqdnVO = fqdnBean.getFqdn();
> Result:
> It returns null
How is your Fqdn instance created? (normally)
Oliver
Re: JSF Value-Binding to Model Object doesnt work
Posted by Andrew Robinson <an...@gmail.com>.
what do your registrations look like for your two beans in your
faces-config.xml? Have you tried using EL to obtain the reference to
fqdnBean?
As far as ui:composition I usually have 1 template for my pages with
the HTML and BODY and then use ui:composition for everything else:
template.xhtml:
<html><body>...</body></html>
page1.xhtml:
<html><body><ui:composition
template="/template.xhtml">...</ui:composition></body></html>
included1.xhtml:
<html><body><ui:composition>...</ui:composition></body></html>
-Andrew
On Mon, Apr 21, 2008 at 11:33 AM, bansi <ma...@yahoo.com> wrote:
>
> Hi Andrew
> Thanks for quick response.
> I tried using managed property but it still returns null.
> I do have <ui:composition> in my code but what i was wondering is when i use
> <ui:include> to include another xhtml file, if i dont have <html> and <body>
> tags in this xhtml file then how can i use jsf tags to build my page.
> Here is the snippet of my included xhtml file
> <?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:ui="http://java.sun.com/jsf/facelets"
> xmlns:h="http://java.sun.com/jsf/html"
> xmlns:f="http://java.sun.com/jsf/core"
> xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
> xmlns:s="http://myfaces.apache.org/sandbox"
> xmlns:t="http://myfaces.apache.org/tomahawk"
> xmlns:c="http://java.sun.com/jstl/core"
> >
>
> <t:saveState value="#{fqdnBean.fqdn}"/>
> <h:outputLabel><h:outputText value="Host Name" /><h:outputText
> style="color: #DD0707" value=" * "/></h:outputLabel>
>
> <h:inputText id="hostName" value="#{fqdnBean.fqdn.name}" style="width:
> 230px"
> styleClass="required max-63" >
> </h:inputText>
> </h:panelGrid>
>
>
>
>
>
>
>
>
> Andrew Robinson-5 wrote:
> >
> > See my reply on the facelets list. You should not be referencing the
> > request context to get a managed bean instance. Either use a managed
> > property, or build an EL expression (or binding for 1.1) and obtain it
> > that way.
> >
> > Beans are lazy loaded and thus should be obtained through the proper API.
> >
> > If you are using facelets, why is there a f:view in your code and why
> > are you not using ui:composition to make sure you do not have 2 BODY
> > tags?
> >
> > On Sun, Apr 20, 2008 at 6:59 PM, bansi <ma...@yahoo.com> wrote:
> >>
> >> I also tried injecting FqdnBean into DeviceBean and then access model
> >> object
> >> of FqdnBean i.e. Fqdn into DeviceBean as
> >> Fqdn fqdnVO = fqdnBean.getFqdn();
> >> Result:
> >> It returns null
> >>
> >>
> >>
> >>
> >>
> >> bansi wrote:
> >> >
> >> > Here is the code sample
> >> >
> >> > <html>
> >> >
> >> > <body>
> >> >
> >> > <f:view>
> >> >
> >> > <h:form id="updateDeviceForm">
> >> >
> >> > <h:panelGrid>
> >> >
> >> > ..........
> >> >
> >> > ..........
> >> >
> >> > <h:inputText id="deviceName" value="#{deviceBean.name}" style="width:
> >> > 230px"
> >> >
> >> > styleClass="required max-63" >
> >> >
> >> >
> >> > </h:panelGrid>
> >> >
> >> >
> >> >
> >> > <h:panelGrid>
> >> >
> >> > <ui:include src="fqdnForm.xhtml"></ui:include>
> >> >
> >> > </h:panelGrid>
> >> >
> >> > </f:view>
> >> >
> >> > </body>
> >> >
> >> > </html>
> >> >
> >> >
> >> >
> >> > Here is the snippet of fqdnForm.xhmtl which has value binding of name
> >> form
> >> > field to model object Fqdn
> >> >
> >> >
> >> >
> >> > <body>
> >> >
> >> > <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
> >> >
> >> > <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}"
> >> style="width:
> >> > 230px"
> >> >
> >> > styleClass="required max-63" >
> >> >
> >> > </h:inputText>
> >> >
> >> > <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
> >> > converter="#{fqdnConverter}"></h:inputHidden>
> >> >
> >> > </h:panelGrid>
> >> >
> >> > </body>
> >> >
> >> >
> >> > The problem is i am unable to access model object fqdn in deviceBean
> >> and
> >> > ofcourse quite obviously i am able to successfully access Fqdn model
> >> > object in FqdnBean.
> >> >
> >> > But as fqdnForm is included in deviceForm i am accessing Fqdn model
> >> object
> >> > or FqdnBean in deviceBean as follows and it returns NULL
> >> > 1)
> >> >
> >> > FqdnBean fqdnBean = (FqdnBean)
> >> >
> >> FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
> >> >
> >> > 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
> >> > "fqdnHidden");
> >> >
> >> >
> >> > Any pointers/suggestions will be highly appreciated
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16800996.html
> >>
> >>
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16808289.html
>
>
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: JSF Value-Binding to Model Object doesnt work
Posted by bansi <ma...@yahoo.com>.
Hi Andrew
Thanks for quick response.
I tried using managed property but it still returns null.
I do have <ui:composition> in my code but what i was wondering is when i use
<ui:include> to include another xhtml file, if i dont have <html> and <body>
tags in this xhtml file then how can i use jsf tags to build my page.
Here is the snippet of my included xhtml file
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
xmlns:s="http://myfaces.apache.org/sandbox"
xmlns:t="http://myfaces.apache.org/tomahawk"
xmlns:c="http://java.sun.com/jstl/core"
>
<t:saveState value="#{fqdnBean.fqdn}"/>
<h:outputLabel><h:outputText value="Host Name" /><h:outputText
style="color: #DD0707" value=" * "/></h:outputLabel>
<h:inputText id="hostName" value="#{fqdnBean.fqdn.name}" style="width:
230px"
styleClass="required max-63" >
</h:inputText>
</h:panelGrid>
Andrew Robinson-5 wrote:
>
> See my reply on the facelets list. You should not be referencing the
> request context to get a managed bean instance. Either use a managed
> property, or build an EL expression (or binding for 1.1) and obtain it
> that way.
>
> Beans are lazy loaded and thus should be obtained through the proper API.
>
> If you are using facelets, why is there a f:view in your code and why
> are you not using ui:composition to make sure you do not have 2 BODY
> tags?
>
> On Sun, Apr 20, 2008 at 6:59 PM, bansi <ma...@yahoo.com> wrote:
>>
>> I also tried injecting FqdnBean into DeviceBean and then access model
>> object
>> of FqdnBean i.e. Fqdn into DeviceBean as
>> Fqdn fqdnVO = fqdnBean.getFqdn();
>> Result:
>> It returns null
>>
>>
>>
>>
>>
>> bansi wrote:
>> >
>> > Here is the code sample
>> >
>> > <html>
>> >
>> > <body>
>> >
>> > <f:view>
>> >
>> > <h:form id="updateDeviceForm">
>> >
>> > <h:panelGrid>
>> >
>> > ..........
>> >
>> > ..........
>> >
>> > <h:inputText id="deviceName" value="#{deviceBean.name}" style="width:
>> > 230px"
>> >
>> > styleClass="required max-63" >
>> >
>> >
>> > </h:panelGrid>
>> >
>> >
>> >
>> > <h:panelGrid>
>> >
>> > <ui:include src="fqdnForm.xhtml"></ui:include>
>> >
>> > </h:panelGrid>
>> >
>> > </f:view>
>> >
>> > </body>
>> >
>> > </html>
>> >
>> >
>> >
>> > Here is the snippet of fqdnForm.xhmtl which has value binding of name
>> form
>> > field to model object Fqdn
>> >
>> >
>> >
>> > <body>
>> >
>> > <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
>> >
>> > <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}"
>> style="width:
>> > 230px"
>> >
>> > styleClass="required max-63" >
>> >
>> > </h:inputText>
>> >
>> > <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
>> > converter="#{fqdnConverter}"></h:inputHidden>
>> >
>> > </h:panelGrid>
>> >
>> > </body>
>> >
>> >
>> > The problem is i am unable to access model object fqdn in deviceBean
>> and
>> > ofcourse quite obviously i am able to successfully access Fqdn model
>> > object in FqdnBean.
>> >
>> > But as fqdnForm is included in deviceForm i am accessing Fqdn model
>> object
>> > or FqdnBean in deviceBean as follows and it returns NULL
>> > 1)
>> >
>> > FqdnBean fqdnBean = (FqdnBean)
>> >
>> FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
>> >
>> > 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
>> > "fqdnHidden");
>> >
>> >
>> > Any pointers/suggestions will be highly appreciated
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16800996.html
>>
>>
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16808289.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF Value-Binding to Model Object doesnt work
Posted by Andrew Robinson <an...@gmail.com>.
See my reply on the facelets list. You should not be referencing the
request context to get a managed bean instance. Either use a managed
property, or build an EL expression (or binding for 1.1) and obtain it
that way.
Beans are lazy loaded and thus should be obtained through the proper API.
If you are using facelets, why is there a f:view in your code and why
are you not using ui:composition to make sure you do not have 2 BODY
tags?
On Sun, Apr 20, 2008 at 6:59 PM, bansi <ma...@yahoo.com> wrote:
>
> I also tried injecting FqdnBean into DeviceBean and then access model object
> of FqdnBean i.e. Fqdn into DeviceBean as
> Fqdn fqdnVO = fqdnBean.getFqdn();
> Result:
> It returns null
>
>
>
>
>
> bansi wrote:
> >
> > Here is the code sample
> >
> > <html>
> >
> > <body>
> >
> > <f:view>
> >
> > <h:form id="updateDeviceForm">
> >
> > <h:panelGrid>
> >
> > ..........
> >
> > ..........
> >
> > <h:inputText id="deviceName" value="#{deviceBean.name}" style="width:
> > 230px"
> >
> > styleClass="required max-63" >
> >
> >
> > </h:panelGrid>
> >
> >
> >
> > <h:panelGrid>
> >
> > <ui:include src="fqdnForm.xhtml"></ui:include>
> >
> > </h:panelGrid>
> >
> > </f:view>
> >
> > </body>
> >
> > </html>
> >
> >
> >
> > Here is the snippet of fqdnForm.xhmtl which has value binding of name form
> > field to model object Fqdn
> >
> >
> >
> > <body>
> >
> > <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
> >
> > <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}" style="width:
> > 230px"
> >
> > styleClass="required max-63" >
> >
> > </h:inputText>
> >
> > <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
> > converter="#{fqdnConverter}"></h:inputHidden>
> >
> > </h:panelGrid>
> >
> > </body>
> >
> >
> > The problem is i am unable to access model object fqdn in deviceBean and
> > ofcourse quite obviously i am able to successfully access Fqdn model
> > object in FqdnBean.
> >
> > But as fqdnForm is included in deviceForm i am accessing Fqdn model object
> > or FqdnBean in deviceBean as follows and it returns NULL
> > 1)
> >
> > FqdnBean fqdnBean = (FqdnBean)
> > FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
> >
> > 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
> > "fqdnHidden");
> >
> >
> > Any pointers/suggestions will be highly appreciated
> >
>
> --
> View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16800996.html
>
>
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>
Re: JSF Value-Binding to Model Object doesnt work
Posted by bansi <ma...@yahoo.com>.
I also tried injecting FqdnBean into DeviceBean and then access model object
of FqdnBean i.e. Fqdn into DeviceBean as
Fqdn fqdnVO = fqdnBean.getFqdn();
Result:
It returns null
bansi wrote:
>
> Here is the code sample
>
> <html>
>
> <body>
>
> <f:view>
>
> <h:form id="updateDeviceForm">
>
> <h:panelGrid>
>
> ..........
>
> ..........
>
> <h:inputText id="deviceName" value="#{deviceBean.name}" style="width:
> 230px"
>
> styleClass="required max-63" >
>
>
> </h:panelGrid>
>
>
>
> <h:panelGrid>
>
> <ui:include src="fqdnForm.xhtml"></ui:include>
>
> </h:panelGrid>
>
> </f:view>
>
> </body>
>
> </html>
>
>
>
> Here is the snippet of fqdnForm.xhmtl which has value binding of name form
> field to model object Fqdn
>
>
>
> <body>
>
> <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
>
> <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}" style="width:
> 230px"
>
> styleClass="required max-63" >
>
> </h:inputText>
>
> <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
> converter="#{fqdnConverter}"></h:inputHidden>
>
> </h:panelGrid>
>
> </body>
>
>
> The problem is i am unable to access model object fqdn in deviceBean and
> ofcourse quite obviously i am able to successfully access Fqdn model
> object in FqdnBean.
>
> But as fqdnForm is included in deviceForm i am accessing Fqdn model object
> or FqdnBean in deviceBean as follows and it returns NULL
> 1)
>
> FqdnBean fqdnBean = (FqdnBean)
> FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
>
> 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
> "fqdnHidden");
>
>
> Any pointers/suggestions will be highly appreciated
>
--
View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16800996.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF Value-Binding to Model Object doesnt work
Posted by bansi <ma...@yahoo.com>.
I will try to explain the problem with code snippet
Here is the code snippet
{code}
<html>
<body>
<f:view>
<h:form id="updateDeviceForm">
<h:panelGrid>
..........
..........
<h:inputText id="deviceName" value="#{deviceBean.name}" style="width: 230px"
styleClass="required max-63" >
</h:panelGrid>
<h:panelGrid>
<ui:include src="fqdnForm.xhtml"></ui:include>
</h:panelGrid>
</f:view>
</body>
</html>
{code}
Here is the snippet of fqdnForm.xhmtl which has value binding of name form
field to model object Fqdn
{code}
<body>
<h:panelGrid columns="3" styleClass="detail" columnClasses="label">
<h:inputText id="hostName" value="#{fqdnBean.fqdn. name}" style="width:
230px"
styleClass="required max-63" >
</h:inputText>
<h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
converter="#{fqdnConverter}"></h:inputHidden>
</h:panelGrid>
</body>
{code}
I am unable to access Model object "Fqdn" In DeviceBean. It returns null
when i access it thru FacesContext . Here is the snippet
{code}
FqdnBean fqdnBean = (FqdnBean)
FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("fqdnBean");
Fqdn fqdnVO = fqdnBean.createValueBindingFqdn();
{code}
Then i tried to access Model object "Fqdn" In DeviceBean by component Id
iterating from viewroot.Here is the snippet
{code}
// Retrieving UIComponent from Tree Model
UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
"fqdnHidden");
Fqdn fqdnVO = (Fqdn) fqdnComp.getValue();
{code}
As the above techniques fails i cant think of any other method. or not sure
what i am making wrong. I dont want to inject FqdnBean into DeviceBean as
managed property as i think the best & effiecient way to access component is
from TreeModel i.e. findComponentById. Here is the snippet
{code}
/**
* Searches view for the component with a specified ID
*
* @param root
* @param id
* @return
*/
@SuppressWarnings("unchecked")
public static UIComponent findComponentById(UIComponent root, String id)
{
if (root == null)
{
// start from the top
root = FacesContext.getCurrentInstance().getViewRoot();
}
UIComponent comp = root.findComponent(id);
if (comp == null)
{
// try to see if there are any nested forms and repeat process
Iterator<UIComponent> iter = root.getFacetsAndChildren();
while (iter.hasNext())
{
UIComponent item = iter.next();
if (HtmlForm.class.isInstance(item))
{
comp = findComponentById(item, id);
if (comp != null)
{
logger.debug("Found component in form:" + item);
break;
}
}
}
}
return comp;
}
{code}
Oliver Becker wrote:
>
> Hi,
> I'm not sure if I fully understand what you're trying to achieve.
> However, here are some suggestions:
>
> 1. If you want to access one managed bean from another (here for
> example fqdnBean from deviceBean) then you should simply declare
> fqdnBean as a managed property for deviceBean. It is completely
> irrelevant (or independent from the fact) that fqdnForm.xhtml is
> included in deviceForm.xhtml.
>
> 2. Are you aware that your included fqdnForm.xhtml defines another
> HTML body? This results in nested body elements in deviceForm which is
> illegal HTML.
>
> 3. I can only guess what the h:inputHidden is for. If you try to save
> the fqdn object to the next request then t:saveState is your friend.
> This element should be placed before any other access to fqdnBean.fqdn
> (particularly before the h:inputText).
>
> Hope this helps,
> Oliver
>
>
> You wrote:
>
>>
>> Here is the code sample
>>
>> <html>
>>
>> <body>
>>
>> <f:view>
>>
>> <h:form id="updateDeviceForm">
>>
>> <h:panelGrid>
>>
>> ..........
>>
>> ..........
>>
>> <h:inputText id="deviceName" value="#{deviceBean.name}"
>> style="width: 230px"
>>
>> styleClass="required max-63" >
>>
>>
>> </h:panelGrid>
>>
>>
>>
>> <h:panelGrid>
>>
>> <ui:include src="fqdnForm.xhtml"></ui:include>
>>
>> </h:panelGrid>
>>
>> </f:view>
>>
>> </body>
>>
>> </html>
>>
>>
>>
>> Here is the snippet of fqdnForm.xhmtl which has value binding of
>> name form
>> field to model object Fqdn
>>
>>
>>
>> <body>
>>
>> <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
>>
>> <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}"
>> style="width:
>> 230px"
>>
>> styleClass="required max-63" >
>>
>> </h:inputText>
>>
>> <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
>> converter="#{fqdnConverter}"></h:inputHidden>
>>
>> </h:panelGrid>
>>
>> </body>
>>
>>
>> The problem is i am unable to access model object fqdn in deviceBean
>> and
>> ofcourse quite obviously i am able to successfully access Fqdn model
>> object
>> in FqdnBean.
>>
>> But as fqdnForm is included in deviceForm i am accessing Fqdn model
>> object
>> or FqdnBean in deviceBean as follows and it returns NULL
>> 1)
>>
>> FqdnBean fqdnBean = (FqdnBean)
>> FacesContext
>> .getCurrentInstance
>> ().getExternalContext().getRequestMap().get("fqdnBean");
>>
>> 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
>> "fqdnHidden");
>>
>>
>> Any pointers/suggestions will be highly appreciated
>> --
>> View this message in context:
>> http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16785936.html
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>
>
>
--
View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16798630.html
Sent from the MyFaces - Users mailing list archive at Nabble.com.
Re: JSF Value-Binding to Model Object doesnt work
Posted by Oliver Becker <ob...@obqo.de>.
Hi,
I'm not sure if I fully understand what you're trying to achieve.
However, here are some suggestions:
1. If you want to access one managed bean from another (here for
example fqdnBean from deviceBean) then you should simply declare
fqdnBean as a managed property for deviceBean. It is completely
irrelevant (or independent from the fact) that fqdnForm.xhtml is
included in deviceForm.xhtml.
2. Are you aware that your included fqdnForm.xhtml defines another
HTML body? This results in nested body elements in deviceForm which is
illegal HTML.
3. I can only guess what the h:inputHidden is for. If you try to save
the fqdn object to the next request then t:saveState is your friend.
This element should be placed before any other access to fqdnBean.fqdn
(particularly before the h:inputText).
Hope this helps,
Oliver
You wrote:
>
> Here is the code sample
>
> <html>
>
> <body>
>
> <f:view>
>
> <h:form id="updateDeviceForm">
>
> <h:panelGrid>
>
> ..........
>
> ..........
>
> <h:inputText id="deviceName" value="#{deviceBean.name}"
> style="width: 230px"
>
> styleClass="required max-63" >
>
>
> </h:panelGrid>
>
>
>
> <h:panelGrid>
>
> <ui:include src="fqdnForm.xhtml"></ui:include>
>
> </h:panelGrid>
>
> </f:view>
>
> </body>
>
> </html>
>
>
>
> Here is the snippet of fqdnForm.xhmtl which has value binding of
> name form
> field to model object Fqdn
>
>
>
> <body>
>
> <h:panelGrid columns="3" styleClass="detail" columnClasses="label">
>
> <h:inputText id="hostName" value="#{fqdnBean.fqdn. name}"
> style="width:
> 230px"
>
> styleClass="required max-63" >
>
> </h:inputText>
>
> <h:inputHidden id="fqdnHidden" value="#{fqdnBean.fqdn}"
> converter="#{fqdnConverter}"></h:inputHidden>
>
> </h:panelGrid>
>
> </body>
>
>
> The problem is i am unable to access model object fqdn in deviceBean
> and
> ofcourse quite obviously i am able to successfully access Fqdn model
> object
> in FqdnBean.
>
> But as fqdnForm is included in deviceForm i am accessing Fqdn model
> object
> or FqdnBean in deviceBean as follows and it returns NULL
> 1)
>
> FqdnBean fqdnBean = (FqdnBean)
> FacesContext
> .getCurrentInstance
> ().getExternalContext().getRequestMap().get("fqdnBean");
>
> 2)UIInput fqdnComp = (UIInput) FacesUtils.findComponentById(null,
> "fqdnHidden");
>
>
> Any pointers/suggestions will be highly appreciated
> --
> View this message in context: http://www.nabble.com/JSF-Value-Binding-to-Model-Object-doesnt-work-tp16785936p16785936.html
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>