Fail to retrieve f:param value

UI Components for JSF
Post Reply
shmu80
Posts: 8
Joined: 21 Apr 2015, 07:04

30 Jun 2015, 07:35

My code is failed to retrieve the p:param value, and it (photoId) is not exists in the RequestParameterMap, but I confirm the value is not null according to the value display from code . May I know what will cause this issue happen?

Code in jsf

Code: Select all

    <p:layout>
        <p:layoutUnit position="west" size="200" minSize="40" maxSize="200">
            ....
            <p:commandButton value="search" ..../>
        </p:layoutUnit>

        <p:layoutUnit position="center">
            <p:panel id="out">
                <p:dataGrid var="biz" value="#{mBean.dataList}" columns="3"
                    layout="grid" rows="12" paginator="true" id="var"
                    paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                    rowsPerPageTemplate="6,12,16">

                    <p:panel style="text-align:center">
                        <p:graphicImage value="#{mBean.image}" width="300"
                            height="300" cache="false">
                                <f:param name="photoId" value="#{var.fullPath}" />
                        </p:graphicImage>
                        <h:outputLabel value="#{var.fullPath}" />

                        ..................
                    </p:panel>
                </p:dataGrid>
            </p:panel>
        </p:layoutUnit>
    </p:layout>
Code in manage bean.

Code: Select all

public StreamedContent getImage() {
    String fileFullPath = FacesUtil.getRequestParameterValue("photoId");
    if (logger.isLoggable(Level.INFO)) {
        logger.info("File full path: " + fileFullPath);
    }
    return FileUtil.genProfileImage(fileFullPath);
}

public static String getRequestParameterValue(String key) {
    if (logger.isLoggable(Level.INFO)) {
        Set<String> itemKeySet = FacesContext.getCurrentInstance()
                .getExternalContext().getRequestParameterMap().keySet();

        for (String itemKey : itemKeySet) {
            logger.info("itemKey: "
                    + itemKey
                    + " : value: "
                    + FacesContext.getCurrentInstance()
                            .getExternalContext().getRequestParameterMap()
                            .get(itemKey));
        }
    }

    return FacesContext.getCurrentInstance().getExternalContext()
            .getRequestParameterMap().get(key);
}
Result : INFO: File full path: null

I am wondering is it the related to the p:layoutUnit. I found only partial of parameter exists in FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap(), and all the existing parameter is located in one of the p:layoutUnit position="west", but all elements in position="center" never appear in the RequestParameterMap.
Last edited by shmu80 on 03 Jul 2015, 03:04, edited 1 time in total.

rosière
Posts: 92
Joined: 28 Nov 2012, 15:55
Contact:

02 Jul 2015, 17:10

Hello,
I read in your XHTML code that you wrote <f:param> instead of "p:param" in your title.
However p:param does not exist. You probably mistyped it in your title.

Also, if I really want to send a parameter with <f:param> component, I shall embed it in the commandButton component.

Code: Select all

  <p:commandButton   action="***"  >
                        <f:param name="xxx" value="yyy" />                                              
                    </p:commandButton>

In your case I think you may need a hidden field component in JSF (<h:inputHidden>) but not <f:param>.

At last, I generally put the command button below the fields to submit, not above them.
JDK: 1.8
Operating system: Windows 10
server: 4.1.1.171 #badassfish (build 136)
IDE: NetBeans 11.2
primefaces : version 6.0
primefaces extensions : 4.0.0
Apache Poi: 3.15

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests