0

I have a Edit Dialog with a Tap to edit (alter, delete, add) OpeningHours (14 inputtexts). At the moment my ui:repeat can show the Strings into the p:inputText. But if I press the "save OPH" button I get an empty List. I already tried to hardcode the index of the list but that also didn't work. After 10h i am out of wits. Maybe somebody can help me. Here my code.

As far as I understood, is that the String class is immutable and doesn't have a setter for the value.

Could it be because of the dialog window? I tried all I could find on solutions on so, so far none worked. Like(Using <ui:repeat><h:inputText> on a List<String> doesn't update model values, Values of h:inputText inside ui:repeat are not processed).

xhtml-file

<p:dialog header="Edit Location" id="locationEditDialog" widgetVar="locationEditDialog"  modal="true" showEffect="fade" hideEffect="fade" responsive="true" width="550">
         <p:outputPanel id="locationData" rendered="#{not empty locationDetailController.location}" >
             <p:tabView widgetVar="tabview" id="tabview">
              <p:tab id="tabDetails3" title="OpeningHours" >
               <div style="padding-left: 14%"><p:outputLabel style="white-space:pre" value="from - to,     from - to"/></div>
                 <ui:repeat  headerText="from-to, break" varStatus="loop" value="#{locationDetailController.hour}" >
                         <div><h:panelGrid columns="3" styleClass="innerpanelgrid" cellpadding="5">
                            <h:outputText value="#{locationDetailController.days[loop.index]}" style="white-space:pre;"/>
                            <p:inputText  value="#{locationDetailController.hour[loop.index]}" size="12"/>
                         </h:panelGrid></div>   
                     </ui:repeat>   
                    <p:commandButton id="saveoph"  value="Save - OPH" 
                            action="#{locationDetailController.doSaveOPH()}"  
                            update=":locationForm:locationTable :locationForm:growlLocation "/>             
                 </p:tab>
               </p:tabView>
             </p:outputPanel>
            </p:dialog>

locationDetailController.java it is os Scope("view")

private List<String> openingHourList;
    


@PostConstruct
    public void init() {
        openingHourList = new ArrayList<>();

    }
    
    public List<String> getHour() {
        
        List<OpeningHours> ohc = openingHourService.getAllOpeningHours().stream().filter(oh -> oh.getLocation().getLocationName() == this.location.getLocationName()).collect(Collectors.toList());
        List<String> openingHoursMapped = new ArrayList<>();

        for (int i = 0; i < 14; i++){
            openingHoursMapped.add("");     
        }

        for(OpeningHours o : ohc) {
            if(o.getBreakTimeStart() == null) {     
                openingHoursMapped.set(o.getDay()-1, o.getOpeningTime() + " - " + o.getClosingTime());
                openingHoursMapped.set(o.getDay()+6, "");
            }
            else {
                openingHoursMapped.set(o.getDay()-1, o.getOpeningTime() + " - " + o.getBreakTimeStart());
                openingHoursMapped.set(o.getDay()+6, o.getBreakTimeEnd() + " - " + o.getClosingTime());
            }
        }
        
        return openingHoursMapped;
        
    }

    public String doSaveOPH() {
        
        System.out.println(openingHourList);
        return "";
    }

    ```


cb1992
  • 1

0 Answers0