You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by mfaine <mf...@knology.net> on 2005/02/01 21:05:34 UTC

RE: pass bean as parameter to JSP

Matthias, in reply to your post:

>
>inside of edit.jsf you got a form (backed to a bean)

>The Bean (backed to edit,jsp) could have a constructor like this:
>  BackingBeanForEditing(){

>String param = (String)
>FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("uniqueId");
 
>if(param!=null){
>	MyCustomObject mco = backend.loadMyObjectByCriteria(param);
>}
>...

I'm attempting to do as you suggested but it seems that something is not
happening in the right order.  When the backing bean is processed the param
is null.  I've tried every way I can think of to initialize this parameter
and still nothing.  Could this be due to the actionListener.  

The tags looks like this:

This is the list box listing documents available for editing.

<h:selectOneListbox id="document"
value="#{currentDocumentsBean.selectedDocumentId}" size="5" style="width:
300px;" required="true">
  <f:selectItems id="documentItem"
value="#{currentDocumentsBean.documentSelectItems}"/>
</h:selectOneListbox>

This is the command button to call the edit action.

<h:commandButton action="#{currentDocumentsBean.editAction}"
value="#{msg.common_edit}"
actionListener="#{currentDocumentsBean.currentDocumentListen}" >
  <f:param name="selectedDocument"
value="#{currentDocumentsBean.selectedDocumentId}" />
</h:commandButton>

In the backing bean for the edit page I check for a reqest parameter
"selectedDocument".  It is always null.


Please forgive the poor formatting, I can only post from the webmail account
provided by my ISP because of some sort of security system of the mailing
list software.

Thanks,
-Mark