You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Daniel Murley <dm...@neuragenix.com> on 2005/06/14 15:23:31 UTC

Displaying and linking search results

Hi all,

I'm currently building on JBoss and MyFaces.  I'm having a problem being
able to link search results to another page.

Effectively what happens at the moment is the user enters some criteria,
hits search, the backing bean in a request scope, grabs the information and
makes it available to the page.

However at this point i'm a little stumped, as I don't know how to be able
to link these results to other pages.

My initial thinking was along the lines of :

<h:commandLink value="#{search.name}" action="#{search.showDetails}">
  <f:param name="searchID" value="#{search.id}" />
</h:commandLink>

However this doesn't seem to be working.  Am I on the right track here, or
is there a better way to do this?

Thanks,

Daniel


No Links working from inside a dataTable/PanelGrid - Was "Displaying and linking search results"

Posted by Daniel Murley <dm...@neuragenix.com>.
After some further testing i'm finding that my commandLinks/Buttons inside
the panelGrid component simply will not work.  Has anyone had ANY success
with this?  I'm finding I can't even get any success with a simple
commandButton that uses the page navigation to move to another page.

Have I missed something fundamental here about the way the panelGrid works?
As I have my datatable nested within a panelGrid, it seems the panelGrid
must be where the failure is occuring.

Here is a snippet of code which is failing :

 <h:panelGrid columns="1" rendered="#{patientSearchCriteria.hasResults}"
width="85%">
				    <h:panelGroup>
					    <h:outputText value="#{search.searchSize}" /> <h:outputText value="
people have been found matching your search criteria." />
					    <f:verbatim><br /></f:verbatim>


				    </h:panelGroup>
					<h:commandButton value="Return to main" action="global_home" />
				 </h:panelGrid>

It doesn't seem to make a difference whether the commandButton is nested in
the group or not.

Thanks

-----Original Message-----
From: "Ricardo R. Ramírez Valenzuela" [mailto:rrrv@itesm.mx]
Sent: Wednesday, 15 June 2005 2:57 AM
To: MyFaces Discussion
Subject: Re: Displaying and linking search results


Into  search.showDetail method:

        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application a = facesContext.getApplication();
        ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
        MyOtherPage page = (MyOtherPage) binding.getValue(facesContext);
        page.setAttribute(theObjectHere);

        If you are printing the search results from the datatable you
may need to get the current row in the datatable and
pass that object to the other linked page.



Daniel Murley wrote:

>Hi all,
>
>I'm currently building on JBoss and MyFaces.  I'm having a problem being
>able to link search results to another page.
>
>Effectively what happens at the moment is the user enters some criteria,
>hits search, the backing bean in a request scope, grabs the information and
>makes it available to the page.
>
>However at this point i'm a little stumped, as I don't know how to be able
>to link these results to other pages.
>
>My initial thinking was along the lines of :
>
><h:commandLink value="#{search.name}" action="#{search.showDetails}">
>  <f:param name="searchID" value="#{search.id}" />
></h:commandLink>
>
>However this doesn't seem to be working.  Am I on the right track here, or
>is there a better way to do this?
>
>Thanks,
>
>Daniel
>
>
>



RE: Displaying and linking search results

Posted by Daniel Murley <dm...@neuragenix.com>.
Ok so in the example, it works.

But my question then becomes, what is the defining factor that actually
makes it work?  I notice there is no use of the <h:form> tag in the
dataTable.jsp.  There is however a use of PanelLayout, but surely this
couldn't make a difference?

It really seems like I'm missing something here, and maybe its something
really obvious, or some sort of conflict, I don't know, but its driving me
crazy!


-----Original Message-----
From: Adrian Merrall [mailto:pigeonracer@gmail.com]
Sent: Wednesday, 15 June 2005 3:48 PM
To: MyFaces Discussion
Subject: Re: Displaying and linking search results


> This thought had actually occured to me, and as such I changed the scope,
> however it had no effect.  Is it possible theres some issue with having
> commandlinks inside datatables?

Yup.  As a complete newbie to anything other than trivial servlets and
JSP pages I struggled with this and found a lot of suggestions but
none worked for me.  Putting the backing bean into the session seemed
to be the most common but that made no change.

In the end I faithfully followed the list example webapp in the source
package.  Look at the examples web app and in particular the
datatable.jsp and countryform.jsp files and their backing beans (IIRC
the backing bean for datatable.jsp is SimpleCountryList.java).

In the examples webapp, look under examples -> components ->
master/detail example to see it in action.

These examples used an x:datatable tag, and x:commandLink and an
x:updateActionListener to ensure the request bean for the individual
item you want to display is set for you.

Once I pretty much made my code exactly the same as the example it
worked very well.

HTH
Adrian



Re: Displaying and linking search results

Posted by Adrian Merrall <pi...@gmail.com>.
> This thought had actually occured to me, and as such I changed the scope,
> however it had no effect.  Is it possible theres some issue with having
> commandlinks inside datatables? 

Yup.  As a complete newbie to anything other than trivial servlets and
JSP pages I struggled with this and found a lot of suggestions but
none worked for me.  Putting the backing bean into the session seemed
to be the most common but that made no change.

In the end I faithfully followed the list example webapp in the source
package.  Look at the examples web app and in particular the
datatable.jsp and countryform.jsp files and their backing beans (IIRC
the backing bean for datatable.jsp is SimpleCountryList.java).

In the examples webapp, look under examples -> components ->
master/detail example to see it in action.

These examples used an x:datatable tag, and x:commandLink and an
x:updateActionListener to ensure the request bean for the individual
item you want to display is set for you.

Once I pretty much made my code exactly the same as the example it
worked very well.

HTH
Adrian

RE: Displaying and linking search results

Posted by Daniel Murley <dm...@neuragenix.com>.
This thought had actually occured to me, and as such I changed the scope,
however it had no effect.  Is it possible theres some issue with having
commandlinks inside datatables?
  -----Original Message-----
  From: "Ricardo R. Ramírez Valenzuela" [mailto:rrrv@itesm.mx]
  Sent: Wednesday, 15 June 2005 11:20 AM
  To: MyFaces Discussion
  Subject: Re: Displaying and linking search results


  You need to restore the component state for the commandLink action to be
fired, is your managed bean "search" request? Try changing it to session and
see if that helps.

  Daniel Murley wrote:
Thanks for the speedy response.

The problem seems to be however that search.showDetail isn't actually firing
at all.  The <h:commandLink> sits inside a <h:dataTable> component, are
there known issues with doing this?  I'm also not specifying any ids for the
commandLink (leaving this up to JSF).

I'd really appreciate any input on this, as I'm finding it exceedingly
frustrating :)

Daniel

-----Original Message-----
From: "Ricardo R. Ramírez Valenzuela" [mailto:rrrv@itesm.mx]
Sent: Wednesday, 15 June 2005 2:57 AM
To: MyFaces Discussion
Subject: Re: Displaying and linking search results


Into  search.showDetail method:

        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application a = facesContext.getApplication();
        ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
        MyOtherPage page = (MyOtherPage) binding.getValue(facesContext);
        page.setAttribute(theObjectHere);

        If you are printing the search results from the datatable you
may need to get the current row in the datatable and
pass that object to the other linked page.



Daniel Murley wrote:

  Hi all,

I'm currently building on JBoss and MyFaces.  I'm having a problem being
able to link search results to another page.

Effectively what happens at the moment is the user enters some criteria,
hits search, the backing bean in a request scope, grabs the information and
makes it available to the page.

However at this point i'm a little stumped, as I don't know how to be able
to link these results to other pages.

My initial thinking was along the lines of :

<h:commandLink value="#{search.name}" action="#{search.showDetails}">
 <f:param name="searchID" value="#{search.id}" />
</h:commandLink>

However this doesn't seem to be working.  Am I on the right track here, or
is there a better way to do this?

Thanks,

Daniel







Re: Displaying and linking search results

Posted by "Ricardo R. Ramírez Valenzuela" <rr...@itesm.mx>.
You need to restore the component state for the commandLink action to be 
fired, is your managed bean "search" request? Try changing it to session 
and see if that helps.

Daniel Murley wrote:

>Thanks for the speedy response.
>
>The problem seems to be however that search.showDetail isn't actually firing
>at all.  The <h:commandLink> sits inside a <h:dataTable> component, are
>there known issues with doing this?  I'm also not specifying any ids for the
>commandLink (leaving this up to JSF).
>
>I'd really appreciate any input on this, as I'm finding it exceedingly
>frustrating :)
>
>Daniel
>
>-----Original Message-----
>From: "Ricardo R. Ramírez Valenzuela" [mailto:rrrv@itesm.mx]
>Sent: Wednesday, 15 June 2005 2:57 AM
>To: MyFaces Discussion
>Subject: Re: Displaying and linking search results
>
>
>Into  search.showDetail method:
>
>        FacesContext facesContext = FacesContext.getCurrentInstance();
>        Application a = facesContext.getApplication();
>        ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
>        MyOtherPage page = (MyOtherPage) binding.getValue(facesContext);
>        page.setAttribute(theObjectHere);
>
>        If you are printing the search results from the datatable you
>may need to get the current row in the datatable and
>pass that object to the other linked page.
>
>
>
>Daniel Murley wrote:
>
>  
>
>>Hi all,
>>
>>I'm currently building on JBoss and MyFaces.  I'm having a problem being
>>able to link search results to another page.
>>
>>Effectively what happens at the moment is the user enters some criteria,
>>hits search, the backing bean in a request scope, grabs the information and
>>makes it available to the page.
>>
>>However at this point i'm a little stumped, as I don't know how to be able
>>to link these results to other pages.
>>
>>My initial thinking was along the lines of :
>>
>><h:commandLink value="#{search.name}" action="#{search.showDetails}">
>> <f:param name="searchID" value="#{search.id}" />
>></h:commandLink>
>>
>>However this doesn't seem to be working.  Am I on the right track here, or
>>is there a better way to do this?
>>
>>Thanks,
>>
>>Daniel
>>
>>
>>
>>    
>>
>
>
>  
>

RE: Displaying and linking search results

Posted by Daniel Murley <dm...@neuragenix.com>.
Thanks for the speedy response.

The problem seems to be however that search.showDetail isn't actually firing
at all.  The <h:commandLink> sits inside a <h:dataTable> component, are
there known issues with doing this?  I'm also not specifying any ids for the
commandLink (leaving this up to JSF).

I'd really appreciate any input on this, as I'm finding it exceedingly
frustrating :)

Daniel

-----Original Message-----
From: "Ricardo R. Ramírez Valenzuela" [mailto:rrrv@itesm.mx]
Sent: Wednesday, 15 June 2005 2:57 AM
To: MyFaces Discussion
Subject: Re: Displaying and linking search results


Into  search.showDetail method:

        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application a = facesContext.getApplication();
        ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
        MyOtherPage page = (MyOtherPage) binding.getValue(facesContext);
        page.setAttribute(theObjectHere);

        If you are printing the search results from the datatable you
may need to get the current row in the datatable and
pass that object to the other linked page.



Daniel Murley wrote:

>Hi all,
>
>I'm currently building on JBoss and MyFaces.  I'm having a problem being
>able to link search results to another page.
>
>Effectively what happens at the moment is the user enters some criteria,
>hits search, the backing bean in a request scope, grabs the information and
>makes it available to the page.
>
>However at this point i'm a little stumped, as I don't know how to be able
>to link these results to other pages.
>
>My initial thinking was along the lines of :
>
><h:commandLink value="#{search.name}" action="#{search.showDetails}">
>  <f:param name="searchID" value="#{search.id}" />
></h:commandLink>
>
>However this doesn't seem to be working.  Am I on the right track here, or
>is there a better way to do this?
>
>Thanks,
>
>Daniel
>
>
>



Re: Displaying and linking search results

Posted by "Ricardo R. Ramírez Valenzuela" <rr...@itesm.mx>.
Into  search.showDetail method:

        FacesContext facesContext = FacesContext.getCurrentInstance();
        Application a = facesContext.getApplication();
        ValueBinding binding = a.createValueBinding("#{" + beanName + "}");
        MyOtherPage page = (MyOtherPage) binding.getValue(facesContext);
        page.setAttribute(theObjectHere);

        If you are printing the search results from the datatable you 
may need to get the current row in the datatable and
pass that object to the other linked page.



Daniel Murley wrote:

>Hi all,
>
>I'm currently building on JBoss and MyFaces.  I'm having a problem being
>able to link search results to another page.
>
>Effectively what happens at the moment is the user enters some criteria,
>hits search, the backing bean in a request scope, grabs the information and
>makes it available to the page.
>
>However at this point i'm a little stumped, as I don't know how to be able
>to link these results to other pages.
>
>My initial thinking was along the lines of :
>
><h:commandLink value="#{search.name}" action="#{search.showDetails}">
>  <f:param name="searchID" value="#{search.id}" />
></h:commandLink>
>
>However this doesn't seem to be working.  Am I on the right track here, or
>is there a better way to do this?
>
>Thanks,
>
>Daniel
>
>  
>