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 2007/08/18 01:03:04 UTC

Unable to pass Object using FacesContext

On click of hyperlink i wanna pass the object instance i.e. address of the
object
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("viewId")

Please note viewId is instance of my object like DeviceView viewId;

I am checking the value at every stage & it holds the address of an object
until i click the link which goes to backing bean method where the value is
null

Any pointers/suggestion highly appreciated
-- 
View this message in context: http://www.nabble.com/Unable-to-pass-Object-using-FacesContext-tf4288541.html#a12208548
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Unable to pass Object using FacesContext

Posted by bansi <ma...@yahoo.com>.
Hi David
Thanks for quick response. 
Here is my code snippet 

<h:dataTable id="deviceDetailTable" styleClass="list" rowClasses="odd,even" 

value="#{updateDeviceBean.tableRows}" var="vartableRow" 

style="">


<h:column id="column1" style="">

<f:facet name="header"><h:outputText value="Id"/></f:facet>

<h:commandLink action="#{updateDeviceBean.loadDeviceInterfaceDetails}"
value="#{vartableRow.viewId}">

<f:param name="interfaceId" value="#{vartableRow.viewId}"/> 

</h:commandLink> 

</h:column>

....

....

</h:dataTable> 



In getTableRows() method i am using pojo to render the content inside
<h:dataTable> as follows



public List doGetTableRows() {


tableRows.add(

new DeviceDetail(

devInterface.getId(), //devInterface.getId() - returns an Object & is
rendered as hyperlink

devInterface.getMac(),

devInterface.getIp(),devInterface.getHostName()

)

);


return tableRows;

}



I understand <f:param> is used only to pass Strings & not Objects. So
<t:updateActionListener ... />  is the solution to pass objects



Regards

Bansi



David Delbecq-2 wrote:
> 
> Not sur what you want, trying to answere anyway.
> 
> 1) If you wanna put information on an HyperLink and have it set to a 
> bean property, one way is to use a lifeCycle listener. At the begin of 
> life cycle,  this listener would look for a series of hardcoded url 
> parameters (like "deviceView") and map the to hardCoded value 
> (#{sessionBean.deviceView}). Note that url parameter must be String, if 
> you want to set complex objects like this, you will have to be able to 
> write them to string and convert them from string.
> 
> 2) If you wanna set an object as a parameter using f:param, be aware 
> that f:param works only for h:commandLink, and not for h:commandButton
> 
> Regards,
> David Delbecq
> bansi a écrit :
>> On click of hyperlink i wanna pass the object instance i.e. address of
>> the
>> object
>> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("viewId")
>>
>> Please note viewId is instance of my object like DeviceView viewId;
>>
>> I am checking the value at every stage & it holds the address of an
>> object
>> until i click the link which goes to backing bean method where the value
>> is
>> null
>>
>> Any pointers/suggestion highly appreciated
>>   
> 
> 

-- 
View this message in context: http://www.nabble.com/Unable-to-pass-Object-using-FacesContext-tf4288541.html#a12242597
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Unable to pass Object using FacesContext

Posted by David Delbecq <de...@oma.be>.
Not sur what you want, trying to answere anyway.

1) If you wanna put information on an HyperLink and have it set to a 
bean property, one way is to use a lifeCycle listener. At the begin of 
life cycle,  this listener would look for a series of hardcoded url 
parameters (like "deviceView") and map the to hardCoded value 
(#{sessionBean.deviceView}). Note that url parameter must be String, if 
you want to set complex objects like this, you will have to be able to 
write them to string and convert them from string.

2) If you wanna set an object as a parameter using f:param, be aware 
that f:param works only for h:commandLink, and not for h:commandButton

Regards,
David Delbecq
bansi a écrit :
> On click of hyperlink i wanna pass the object instance i.e. address of the
> object
> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("viewId")
>
> Please note viewId is instance of my object like DeviceView viewId;
>
> I am checking the value at every stage & it holds the address of an object
> until i click the link which goes to backing bean method where the value is
> null
>
> Any pointers/suggestion highly appreciated
>   

Re: Unable to pass Object using FacesContext

Posted by bansi <ma...@yahoo.com>.
Further to my below posting i added the following code which works only once
. I guess its due to session bean

FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
application.createValueBinding
("#{updateDeviceBean.viewId}").setValue(context, devInterface.getId());



bansi wrote:
> 
> Forgot to mention i dont wanna use managed-property facility  in the
> faces-config as i am using Session scope Bean and i cant use request scope
> bean
> 
> 
> bansi wrote:
>> 
>> On click of hyperlink i wanna pass the object instance i.e. address of
>> the object
>> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("viewId")
>> 
>> Please note viewId is instance of my object like DeviceView viewId;
>> 
>> I am checking the value at every stage & it holds the address of an
>> object until i click the link which goes to backing bean method where the
>> value is null
>> 
>> Any pointers/suggestion highly appreciated
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Unable-to-pass-Object-using-FacesContext-tf4288541.html#a12209058
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: Unable to pass Object using FacesContext

Posted by bansi <ma...@yahoo.com>.
Forgot to mention i dont wanna use managed-property facility  in the
faces-config as i am using Session scope Bean and i cant use request scope
bean


bansi wrote:
> 
> On click of hyperlink i wanna pass the object instance i.e. address of the
> object
> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("viewId")
> 
> Please note viewId is instance of my object like DeviceView viewId;
> 
> I am checking the value at every stage & it holds the address of an object
> until i click the link which goes to backing bean method where the value
> is null
> 
> Any pointers/suggestion highly appreciated
> 

-- 
View this message in context: http://www.nabble.com/Unable-to-pass-Object-using-FacesContext-tf4288541.html#a12208627
Sent from the MyFaces - Users mailing list archive at Nabble.com.