New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PartialSubmit: support SelectOneRadio with custom layout #4327

Closed
OBreidenbach opened this Issue Dec 13, 2018 · 5 comments

Comments

Projects
None yet
3 participants
@OBreidenbach
Copy link
Contributor

OBreidenbach commented Dec 13, 2018

1) Environment

2) Expected behavior

If I have a p:ajax component inside p:selectOneRadio I expect that it is working the same independent of the used layout.

3) Actual behavior

If custom layout is used for p:selectOneRadio and partialSubmit=true for the p:ajax component. The value is not submitted

4) Steps to reproduce

Click on the radio buttons in the example and have look at the parameter in the request with the developer tools of the browser.
If standard layout is used you will find the parameter: form:standard:Option1
If custom layout is uesd the parameter is missing

5) Sample XHTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html">

    <h:head>
        <title>PrimeFaces Test</title>
    </h:head>
    <h:body>
        <h:form id="form">
            <!--<p:log />-->
            <h1>Standard</h1>
            <p:selectOneRadio id="standard"
                              value="#{testView.selected}">
                <p:ajax partialSubmit="true" process="@this"/>
                <f:selectItems value="#{testView.options}" />
            </p:selectOneRadio>

            <h1>Custom</h1>
            <p:selectOneRadio id="custom"
                              value="#{testView.selected}"
                              layout="custom">
                <p:ajax partialSubmit="true" process="@this"/>
                <f:selectItems value="#{testView.options}"/>
            </p:selectOneRadio>
            <!-- Radiobuttons -->
            <p:repeat id="custom_options"
                      value="#{testView.options}"
                      var="option"
                      varStatus="status">
                <!-- Radiobutton -->
                <p:radioButton id="option"
                               for="form:custom"
                               itemIndex="#{status.index}"/>
                <!-- Label -->
                <label for="form:custom:#{status.index}_clone">
                    <h:outputText value="#{option.label}"/>
                </label>
            </p:repeat>

            <h1>Custom with container</h1>
            <p:outputPanel id="container">
            <p:selectOneRadio id="customConainer"
                              value="#{testView.selected}"
                              layout="custom">
                <p:ajax partialSubmit="true" process="container"/>
                <f:selectItems value="#{testView.options}"/>
            </p:selectOneRadio>
            <!-- Radiobuttons -->
            <p:repeat id="customConainer_options"
                      value="#{testView.options}"
                      var="option"
                      varStatus="status">
                <!-- Radiobutton -->
                <p:radioButton id="optionContainer"
                               for="form:customConainer"
                               itemIndex="#{status.index}"/>
                <!-- Label -->
                <label for="form:customConainer:#{status.index}_clone">
                    <h:outputText value="#{option.label}"/>
                </label>
            </p:repeat>
            </p:outputPanel>

        </h:form>
    </h:body>
</html>

6) Sample bean

package org.primefaces.test;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.model.SelectItem;

@ManagedBean(name = "testView")
@ViewScoped
public class TestView implements Serializable {

    private List<SelectItem> options = Arrays.asList(
            new SelectItem("Option1"), new SelectItem("Option2")
    );

    private String selected;

    public List<SelectItem> getOptions() {
        return options;
    }

    public String getSelected() {
        return selected;
    }

    public void setSelected(String selected) {
        this.selected = selected;
    }
}

The testcase:
https://github.com/OBreidenbach/primefaces-test/tree/PF4327

@tandraschko

This comment has been minimized.

Copy link
Member

tandraschko commented Dec 13, 2018

Did you try IT with trunk?

@OBreidenbach

This comment has been minimized.

Copy link
Contributor

OBreidenbach commented Dec 13, 2018

I tested with 6.2 and trunk (6.3-SNAPSHOT) of today.

@tandraschko

This comment has been minimized.

Copy link
Member

tandraschko commented Dec 13, 2018

ok, a PR would be great.

@OBreidenbach

This comment has been minimized.

Copy link
Contributor

OBreidenbach commented Dec 13, 2018

As workaround I put the selectOneRadio and the custom layout into a p:outputPanel and use this surrounding panel for the process attribute.

<p:outputPanel id="container">
    <p:selectOneRadio id="customConainer"
                      value="#{testView.selected}"
                      layout="custom">
        <p:ajax partialSubmit="true" process="container"/>
        <f:selectItems value="#{testView.options}"/>
    </p:selectOneRadio>
    <!-- Radiobuttons -->
    <p:repeat id="customConainer_options"
              value="#{testView.options}"
              var="option"
              varStatus="status">
        <!-- Radiobutton -->
        <p:radioButton id="optionContainer"
                       for="form:customConainer"
                       itemIndex="#{status.index}"/>
        <!-- Label -->
        <label for="form:customConainer:#{status.index}_clone">
            <h:outputText value="#{option.label}"/>
        </label>
    </p:repeat>
</p:outputPanel>
@tandraschko

This comment has been minimized.

Copy link
Member

tandraschko commented Dec 14, 2018

Yep, therefore it's not a bug in the partialSubmit logic.
The case with custom layout is quite special as the inputs are not below the processed component. Therefore partialSubmit logic doesn't collect it.

@tandraschko tandraschko changed the title SelectOneRadio: value not submitted by ajax partialSubmit PartialSubmit: support SelectOneRadio with custom layout Dec 14, 2018

@mertsincan mertsincan self-assigned this Jan 8, 2019

@mertsincan mertsincan added the 6.2.14 label Jan 8, 2019

@mertsincan mertsincan added this to the 6.3 milestone Jan 8, 2019

@mertsincan mertsincan closed this in 4e56428 Jan 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment