0

I am stuck with a problem, the problem is I am using a side bar and there is are certain components inside it. I want to update these components when user changes it using ajax. But I am facing issue with passing parameters to bean from primefaces component,my controller needs the parameters. I am trying the following code, any solution will be highly appreciated.

The .xhtml looks like this.

<p:outputPanel id="out">
    <p:sidebar widgetVar="sidebar" position="right" baseZIndex="10000">
        <h3>Right Sidebar</h3>
        <h:panelGrid style="border-color: white" columns="2" cellpadding="7">
            <h:outputText for="falsePositive" value="False Positive" />
            <p:selectBooleanCheckbox id="falsePositive" style = "display: inline-block; border:solid 1px black" value="#{controller.falsePositive}">
                <p:ajax update="out" />
            </p:selectBooleanCheckbox>
        </h:panelGrid>
    </p:sidebar>
</p:outputPanel>

My controller looks like this

private static final String AJAX_PARAM_Id = "id";
public Boolean getFalsePositive(){
        String id = getRequestParameter(AJAX_PARAM_Id);
        input = inputRepository.find(id);
        return input.getFalsePositive();
}

public void setFalsePositive(Boolean falsePositive){
    input.setFalsePositive(falsePositive);
    save(input)

}
Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
  • To clarify this sidebar is a part of datatable column and i can pass the field id to the controller from my .xhtml – Ankit Prasad Jul 14 '21 at 06:24
  • What's the problem exactly? You cannot pass any parameter to the bean or you cannot update your components whenever the checkbox change its value? – Simone Lungarella Jul 14 '21 at 07:14
  • The problem is I don't know how to pass parameter to the bean from .xhtml – Ankit Prasad Jul 14 '21 at 07:25
  • Thanks @SimoneLungarella for answering. The problem is I don't know how to pass parameter to the bean from .xhtml. I want to achieve the following wheneever user changes the sidebar values, I want to update these values in the db through ajax, there is no save button. – Ankit Prasad Jul 14 '21 at 07:32
  • Does this answer your question? [Send additional parameter to Ajax event listener](https://stackoverflow.com/questions/39143601/send-additional-parameter-to-ajax-event-listener) – Jasper de Vries Jul 14 '21 at 08:10
  • Tried something like this :- But I am unable to get the value in the RequestParameterMap in java. The thing is I want the parameter to be available in my getter (getFalsePositive()) too. – Ankit Prasad Jul 14 '21 at 09:04

0 Answers0