PageData.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */




  20. package org.openspcoop2.web.lib.mvc;

  21. import java.io.Serializable;
  22. import java.text.MessageFormat;
  23. import java.util.ArrayList;
  24. import java.util.HashMap;
  25. import java.util.List;
  26. import java.util.Map;

  27. import org.apache.commons.lang.StringUtils;
  28. import org.openspcoop2.web.lib.mvc.DataElement.STATO_APERTURA_SEZIONI;

  29. /**
  30.  * PageData
  31.  *
  32.  * @author Andrea Poli (apoli@link.it)
  33.  * @author Stefano Corallo (corallo@link.it)
  34.  * @author Sandra Giangrandi (sandra@link.it)
  35.  * @author $Author$
  36.  * @version $Rev$, $Date$
  37.  *
  38.  */
  39. public class PageData implements Serializable {

  40.     /**
  41.      *
  42.      */
  43.     private static final long serialVersionUID = 1L;
  44.     String pageDescription;
  45.     String search;
  46.     String searchDescription;
  47.     boolean searchNote = false;
  48.     String searchLabel;
  49.     int searchNumEntries;
  50.     String mode;
  51.     String message;
  52.     String messageType;
  53.     String messageTitle;
  54.     List<GeneralLink> titlelist;
  55.     List<?> dati;
  56.     List<?> menu;
  57.     List<?> areaBottoni;
  58.     Map<String,String> hidden;
  59.     String page;
  60.     String op;
  61.     String [] labels;
  62.     String [][] bottoni = null; // x info-page
  63.     boolean inserisciBottoni;
  64.     boolean addButton;
  65.     boolean removeButton;
  66.     boolean select;
  67.     List<DataElement> filterNames = null;
  68.     List<DataElement> filterValues = null;
  69.     int pageSize, index, numEntries;
  70.     boolean mostraLinkHome = false;
  71.     List<String> linkHomeLabels = null;
  72.     String customListViewName = null;
  73.     String labelBottoneInvia = null;
  74.     String labelBottoneFiltra = null;
  75.     String labelBottoneRipulsci = null;
  76.    
  77.     private boolean showAjaxStatusBottoneInvia = true;
  78.     private boolean showAjaxStatusBottoneFiltra = true;
  79.     private boolean showAjaxStatusBottoneRipulisci = true;
  80.    
  81.     private List<DataElement> comandiAzioneBarraTitoloDettaglioElemento;
  82.    
  83.    
  84.     Dialog dialog = null;

  85.     boolean postBackResult=false;
  86.     boolean includiMenuLateraleSx = true;
  87.    
  88.     private boolean paginazione = true;
  89.    
  90.     private boolean inserisciSearch = true;
  91.    
  92.     public PageData() {
  93.         this.pageDescription = "";
  94.         this.search = "auto";
  95.         this.searchDescription = "";
  96.         this.searchLabel = "Ricerca";
  97.         this.searchNote = false;
  98.         //this.searchNumEntries = 10;
  99.         this.searchNumEntries = -1; // Per visualizzare sempre
  100.         this.mode = "";
  101.         this.message = "";
  102.         this.messageType = MessageType.ERROR.toString();
  103.         this.messageTitle = "";
  104.         this.page = "";
  105.         this.op = "";
  106.         this.titlelist = new ArrayList<>();
  107.         this.dati = new ArrayList<>();
  108.         this.menu = new ArrayList<>();
  109.         this.areaBottoni = new ArrayList<>();
  110.         this.hidden = new HashMap<>();
  111.         this.inserisciBottoni = true;
  112.         this.addButton = true;
  113.         this.removeButton = true;
  114.         this.select = true;
  115.         this.pageSize = 20;
  116.         this.index = 0;
  117.         this.numEntries = 0;
  118.         this.mostraLinkHome = false;
  119.         this.customListViewName = null;
  120.         this.labelBottoneInvia = Costanti.LABEL_MONITOR_BUTTON_INVIA;
  121.         this.labelBottoneFiltra = Costanti.LABEL_MONITOR_BUTTON_FILTRA;
  122.         this.labelBottoneRipulsci = Costanti.LABEL_MONITOR_BUTTON_RIPULISCI;
  123.         this.postBackResult=false;
  124.         this.includiMenuLateraleSx = true;
  125.         this.paginazione = true;
  126.         this.comandiAzioneBarraTitoloDettaglioElemento = new ArrayList<>();
  127.         this.setInserisciSearch(true);
  128.     }

  129.     public void setPageDescription(String s) {
  130.         this.pageDescription = s;
  131.     }
  132.     public String getPageDescription() {
  133.         return this.pageDescription;
  134.     }

  135.     public int getSearchNumEntries() {
  136.         return this.searchNumEntries;
  137.     }
  138.     public void setSearchNumEntries(int searchNumEntries) {
  139.         this.searchNumEntries = searchNumEntries;
  140.     }
  141.    
  142.     public String getSearchLabel() {
  143.         return this.searchLabel;
  144.     }
  145.     public void setSearchLabel(String searchLabel) {
  146.         this.searchLabel = searchLabel;
  147.     }
  148.    
  149.     public boolean isSearchNote() {
  150.         return this.searchNote;
  151.     }
  152.     public void setSearchNote(boolean searchNote) {
  153.         this.searchNote = searchNote;
  154.     }
  155.    
  156.     public void setSearch(String s) {
  157.         this.search = s;
  158.     }
  159.     public String getSearch() {
  160.         return this.search;
  161.     }

  162.     public void setSearchDescription(String s) {
  163.         this.searchDescription = s;
  164.     }
  165.     public String getSearchDescription() {
  166.         if(this.searchDescription != null && !this.searchDescription.equals("")){
  167.             int idx1 = this.searchDescription.indexOf("'");
  168.             int idx2 = this.searchDescription.lastIndexOf("'");

  169.             if(idx1 > -1 && idx2 > -1){
  170.                 // elimino ' di destra
  171.                 String s = this.searchDescription.substring(0, idx2);
  172.                 // elimino ' di sinistra
  173.                 return s.substring(idx1 +1);                
  174.             }
  175.         }
  176.         return this.searchDescription;
  177.     }

  178.     public void setMode(String s) {
  179.         this.mode = s;
  180.     }
  181.     public void disableEditMode() {
  182.         this.mode = Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME;
  183.     }
  184.     public void disableOnlyButton() {
  185.         this.mode = Costanti.DATA_ELEMENT_DISABLE_ONLY_BUTTON;
  186.     }
  187.     public String getMode() {
  188.         return this.mode;
  189.     }
  190.     public boolean isDisableEditMode() {
  191.         return Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME.equals(this.mode);
  192.     }

  193.     public void setMessage(String s) {
  194.         this.setMessage(s, MessageType.ERROR);
  195.     }
  196.    
  197.     public void setMessage(String s,MessageType type) {
  198.         setMessage(s, null, type);
  199.     }
  200.     public void setMessage(String s, String title, MessageType type) {
  201.         this.message = s;
  202.         this.messageType = type.toString();
  203.         this.messageTitle = title;
  204.         if(this.messageTitle == null) {
  205.             switch (type) {
  206.             case CONFIRM:
  207.                 this.messageTitle = Costanti.MESSAGE_TYPE_CONFIRM_TITLE;
  208.                 break;
  209.             case ERROR:
  210.                 this.messageTitle = Costanti.MESSAGE_TYPE_ERROR_TITLE;
  211.                 break;
  212.             case WARN:
  213.                 this.messageTitle = Costanti.MESSAGE_TYPE_WARN_TITLE;
  214.                 break;
  215.             case INFO:
  216.                 this.messageTitle = Costanti.MESSAGE_TYPE_INFO_TITLE;
  217.                 break;
  218.             case INFO_SINTETICO:
  219.             case ERROR_SINTETICO:
  220.             case WARN_SINTETICO:
  221.                 this.messageTitle = this.message;
  222.                 break;
  223.             case DIALOG:
  224.                 this.messageTitle = Costanti.MESSAGE_TYPE_DIALOG_TITLE;
  225.                 break;
  226.             }
  227.         }
  228.     }

  229.     public String getMessage() {
  230.         return this.message;
  231.     }

  232.     public String getMessageType() {
  233.         return this.messageType;
  234.     }

  235.     public void setMessageType(String messageType) {
  236.         this.messageType = messageType;
  237.     }
  238.    
  239.     public String getMessageTitle() {
  240.         return this.messageTitle;
  241.     }

  242.     public void setPage(String s) {
  243.         this.page = s;
  244.     }
  245.     public String getPage() {
  246.         return this.page;
  247.     }

  248.     public void setOp(String s) {
  249.         this.op = s;
  250.     }
  251.     public String getOp() {
  252.         return this.op;
  253.     }

  254.     public void setTitleList(List<GeneralLink> v) {
  255.         this.titlelist = v;
  256.     }
  257.     public List<GeneralLink> getTitleList() {
  258.         return this.titlelist;
  259.     }

  260.     public void setDati(List<?> v) {
  261.         this.dati = v;
  262.     }
  263.     public List<?> getDati() {
  264.         return this.dati;
  265.     }

  266.     public void setMenu(List<?> v) {
  267.         this.menu = v;
  268.     }
  269.     public List<?> getMenu() {
  270.         return this.menu;
  271.     }

  272.     public void setAreaBottoni(List<?> v) {
  273.         this.areaBottoni = v;
  274.     }
  275.     public List<?> getAreaBottoni() {
  276.         return this.areaBottoni;
  277.     }

  278.     /* hidden */
  279.     public void setHidden(Map<String,String> v) {
  280.         this.hidden = v;
  281.     }
  282.     public Map<String,String> getHidden() {
  283.         return this.hidden;
  284.     }
  285.     public void addHidden(String name, String value) {
  286.         this.hidden.put(name,value);
  287.     }
  288.     public String getHidden(String name) {
  289.         String value = this.hidden.get(name);
  290.         return value;
  291.     }
  292.     public void clearHidden() {
  293.         this.hidden.clear();
  294.     }

  295.     public void setLabels(String [] s) {
  296.         if( s != null && s.length > 0){
  297.             this.labels = new String[ s.length];
  298.             for (int i = 0; i < s.length; i++) {
  299.                 this.labels[i] = DataElement.getEscapedValue( s[i]);
  300.             }
  301.         }else {
  302.             this.labels = s;
  303.         }
  304.     }
  305.     public String [] getLabels() {
  306.         return this.labels;
  307.     }

  308.     public void setBottoni(String [][] s) {
  309.         this.bottoni = s;
  310.     }
  311.     public String [][] getBottoni() {
  312.         return this.bottoni;
  313.     }

  314.     public void setInserisciBottoni(boolean b) {
  315.         this.inserisciBottoni = b;
  316.     }
  317.     public boolean getInserisciBottoni() {
  318.         return this.inserisciBottoni;
  319.     }

  320.     public void setAddButton(boolean b) {
  321.         this.addButton = b;
  322.     }
  323.     public boolean getAddButton() {
  324.         return this.addButton;
  325.     }

  326.     public void setSelect(boolean b) {
  327.         this.select = b;
  328.     }
  329.     public boolean getSelect() {
  330.         return this.select;
  331.     }

  332.     public void setRemoveButton(boolean b) {
  333.         this.removeButton = b;
  334.     }
  335.     public boolean getRemoveButton() {
  336.         return this.removeButton;
  337.     }

  338.     public static String GET_PARAMETRO_FILTER_NAME (int position) {
  339.         return Costanti.PARAMETRO_FILTER_NAME+position;
  340.     }
  341.     public static String GET_PARAMETRO_FILTER_VALUE (int position) {
  342.         return Costanti.PARAMETRO_FILTER_VALUE+position;
  343.     }
  344.    
  345.     public void addFilter(String name, String label, String valueSelected, String [] values, String [] labels, boolean postBack, int size) throws Exception{
  346.         this.addFilter(name, label, valueSelected, values, labels, postBack, size, false);
  347.     }
  348.    
  349.     public void addFilter(String name, String label, String valueSelected, String [] values, String [] labels, boolean postBack, int size, boolean disabilitaFiltroRisultati) throws Exception{
  350.         if(this.filterNames == null) {
  351.             this.filterNames = new ArrayList<>();
  352.             this.filterValues = new ArrayList<>();
  353.         }
  354.        
  355.         DataElement deName = new DataElement();
  356.         deName.setType(DataElementType.HIDDEN);
  357.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  358.         if(name==null) {
  359.             throw new Exception("Name not found");
  360.         }
  361.         deName.setValue(name);
  362.         this.filterNames.add(deName);
  363.        
  364.         DataElement deValue = new DataElement();
  365.         deValue.setType(DataElementType.SELECT);
  366.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  367.         if(label==null) {
  368.             throw new Exception("Label not found");
  369.         }
  370.         deValue.setLabel(label);
  371.         deValue.setSelected(valueSelected);
  372.         deValue.setValue(valueSelected);
  373.         if(values==null || values.length<=0) {
  374.             throw new Exception("Values not found");
  375.         }
  376.         deValue.setValues(values);
  377.         deValue.setLabels(labels);
  378.         deValue.setSize(size);
  379.         deValue.setPostBack(postBack);
  380.         if(disabilitaFiltroRisultati)
  381.             deValue.disabilitaFiltroOpzioniSelect();
  382.         this.filterValues.add(deValue);
  383.        
  384.     }
  385.    
  386.     public void addTextFilter(String name, String label, String value, int size) throws Exception{
  387.         if(this.filterNames == null) {
  388.             this.filterNames = new ArrayList<>();
  389.             this.filterValues = new ArrayList<>();
  390.         }
  391.        
  392.         DataElement deName = new DataElement();
  393.         deName.setType(DataElementType.HIDDEN);
  394.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  395.         if(name==null) {
  396.             throw new Exception("Name not found");
  397.         }
  398.         deName.setValue(name);
  399.         this.filterNames.add(deName);
  400.        
  401.         DataElement deValue = new DataElement();
  402.         deValue.setType(DataElementType.TEXT_EDIT);
  403.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  404.         if(label==null) {
  405.             throw new Exception("Label not found");
  406.         }
  407.         deValue.setLabel(label);
  408.         deValue.setValue(value);
  409.         deValue.setSize(size);
  410.         this.filterValues.add(deValue);
  411.     }
  412.    
  413.     public void addTextAreaFilter(String name, String label, String value, int size, Integer rows, Integer cols) throws Exception{
  414.         if(this.filterNames == null) {
  415.             this.filterNames = new ArrayList<>();
  416.             this.filterValues = new ArrayList<>();
  417.         }
  418.        
  419.         DataElement deName = new DataElement();
  420.         deName.setType(DataElementType.HIDDEN);
  421.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  422.         if(name==null) {
  423.             throw new Exception("Name not found");
  424.         }
  425.         deName.setValue(name);
  426.         this.filterNames.add(deName);
  427.        
  428.         DataElement deValue = new DataElement();
  429.         deValue.setType(DataElementType.TEXT_AREA);
  430.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  431.         if(label==null) {
  432.             throw new Exception("Label not found");
  433.         }
  434.         deValue.setLabel(label);
  435.         deValue.setValue(value);
  436.         deValue.setSize(size);
  437.         if(rows != null)
  438.             deValue.setRows(rows.intValue());
  439.         if(cols != null)
  440.             deValue.setCols(cols.intValue());
  441.        
  442.         this.filterValues.add(deValue);
  443.     }
  444.    
  445.     public void addNumberFilter(String name, String label, String value, int size, Integer min, Integer max) throws Exception{
  446.         if(this.filterNames == null) {
  447.             this.filterNames = new ArrayList<>();
  448.             this.filterValues = new ArrayList<>();
  449.         }
  450.        
  451.         DataElement deName = new DataElement();
  452.         deName.setType(DataElementType.HIDDEN);
  453.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  454.         if(name==null) {
  455.             throw new Exception("Name not found");
  456.         }
  457.         deName.setValue(name);
  458.         this.filterNames.add(deName);
  459.        
  460.         DataElement deValue = new DataElement();
  461.         deValue.setType(DataElementType.NUMBER);
  462.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  463.         if(label==null) {
  464.             throw new Exception("Label not found");
  465.         }
  466.         deValue.setLabel(label);
  467.         deValue.setValue(value);
  468.         deValue.setSize(size);
  469.         deValue.setMinValue(min);
  470.         deValue.setMaxValue(max);
  471.         this.filterValues.add(deValue);
  472.     }
  473.    
  474.     public void addCheckboxFilter(String name, String label, String value, int size) throws Exception{
  475.         if(this.filterNames == null) {
  476.             this.filterNames = new ArrayList<>();
  477.             this.filterValues = new ArrayList<>();
  478.         }
  479.        
  480.         DataElement deName = new DataElement();
  481.         deName.setType(DataElementType.HIDDEN);
  482.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  483.         if(name==null) {
  484.             throw new Exception("Name not found");
  485.         }
  486.         deName.setValue(name);
  487.         this.filterNames.add(deName);
  488.        
  489.         DataElement deValue = new DataElement();
  490.         deValue.setType(DataElementType.CHECKBOX);
  491.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  492.         if(label==null) {
  493.             throw new Exception("Label not found");
  494.         }
  495.         deValue.setLabel(label);
  496.         deValue.setValue(value);
  497.         deValue.setSelected(value);
  498.         deValue.setSize(size);
  499.         this.filterValues.add(deValue);
  500.     }
  501.    
  502.     public void addSubtitleFilter(String name, String label, boolean visualizzaSottosezioneAperta) throws Exception{
  503.         if(this.filterNames == null) {
  504.             this.filterNames = new ArrayList<>();
  505.             this.filterValues = new ArrayList<>();
  506.         }
  507.        
  508.         // devo salvare anche l'elemento name perche' la jsp naviga sia names che values contemporaneamente per posizione.
  509.         DataElement deName = new DataElement();
  510.         deName.setType(DataElementType.HIDDEN);
  511.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  512.         if(name==null) {
  513.             throw new Exception("Name not found");
  514.         }
  515.         deName.setValue(name);
  516.         this.filterNames.add(deName);
  517.        
  518.         DataElement deValue = new DataElement();
  519.         deValue.setType(DataElementType.SUBTITLE);
  520.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  521.         if(label==null) {
  522.             throw new Exception("Label not found");
  523.         }
  524.         deValue.setLabel(label);
  525.         deValue.setStatoAperturaSezioni(visualizzaSottosezioneAperta ? STATO_APERTURA_SEZIONI.APERTO : STATO_APERTURA_SEZIONI.CHIUSO);
  526.         this.filterValues.add(deValue);
  527.     }
  528.    
  529.    
  530.     public void impostaAperturaSubtitle(String name, Boolean visualizzaSottosezioneAperta, String postbackElementName) throws Exception {
  531.        
  532.         if(name==null) {
  533.             throw new Exception("Param name is null");
  534.         }
  535.        
  536.         if(this.filterNames != null) {
  537.             int idxSubtitle = -1;
  538.             for (int i = 0; i < this.filterNames.size(); i++) {
  539.                 if(name.equals(this.filterNames.get(i).getValue())) {
  540.                     idxSubtitle = i;
  541.                     break;
  542.                 }
  543.             }
  544.            
  545.             if(visualizzaSottosezioneAperta == null) {
  546.                 // se ho trovato il subtitle allora prendo i filtri successivi
  547.                 // finche non trovo un altro subtitle o finisce la lista
  548.                 if(idxSubtitle > -1) {
  549.                     List<DataElement> filterValuesToCheck = new ArrayList<>();
  550.                    
  551.                     for (int i = idxSubtitle + 1; i < this.filterNames.size(); i++) {
  552.                         DataElement de = this.filterValues.get(i);
  553.                         if(de.getType().equals("subtitle")) {
  554.                             // ho trovato un'altra sezione mi fermo
  555.                             break;
  556.                         } else {
  557.                             filterValuesToCheck.add(de);
  558.                         }
  559.                     }
  560.                     visualizzaSottosezioneAperta = this.hasAlmostOneFilterDefined(filterValuesToCheck);
  561.                    
  562.                     // se c'e' stata una postback la sezione dell'elemento che ha provocato il reload deve restare aperta
  563.                     if(postbackElementName != null) {
  564.                         for (int i = 0; i < filterValuesToCheck.size(); i++) {
  565.                             if(filterValuesToCheck.get(i).getName().equals(postbackElementName)) {
  566.                                 visualizzaSottosezioneAperta = true;
  567.                                 break;
  568.                             }
  569.                         }
  570.                     }
  571.                 }
  572.             }
  573.            
  574.             if(visualizzaSottosezioneAperta!=null) {
  575.                 this.updateSubtitleFilter(name, visualizzaSottosezioneAperta);
  576.             }
  577.         }
  578.     }
  579.    
  580.     public void updateSubtitleFilter(String name, boolean visualizzaSottosezioneAperta) {
  581.         if(this.filterNames != null) {
  582.             for (int i = 0; i < this.filterNames.size(); i++) {
  583.                 if(name.equals(this.filterNames.get(i).getValue())) {
  584.                     this.filterValues.get(i).setStatoAperturaSezioni(visualizzaSottosezioneAperta ? STATO_APERTURA_SEZIONI.APERTO : STATO_APERTURA_SEZIONI.CHIUSO);
  585.                     break;
  586.                 }
  587.             }
  588.         }
  589.     }
  590.    
  591.     public void addHiddenFilter(String name, String value, int size) throws Exception{
  592.         if(this.filterNames == null) {
  593.             this.filterNames = new ArrayList<>();
  594.             this.filterValues = new ArrayList<>();
  595.         }
  596.        
  597.         DataElement deName = new DataElement();
  598.         deName.setType(DataElementType.HIDDEN);
  599.         deName.setName(GET_PARAMETRO_FILTER_NAME(this.filterNames.size()));
  600.         if(name==null) {
  601.             throw new Exception("Name not found");
  602.         }
  603.         deName.setValue(name);
  604.         this.filterNames.add(deName);
  605.        
  606.         DataElement deValue = new DataElement();
  607.         deValue.setType(DataElementType.HIDDEN);
  608.         deValue.setName(GET_PARAMETRO_FILTER_VALUE(this.filterValues.size()));
  609.         deValue.setLabel(deValue.getName());
  610.         deValue.setValue(value);
  611.         deValue.setSize(size);
  612.         this.filterValues.add(deValue);
  613.     }
  614.    
  615.     public void updateFilter(String name, String value) {
  616.         if(this.filterNames != null) {
  617.             for (int i = 0; i < this.filterNames.size(); i++) {
  618.                 if(name.equals(this.filterNames.get(i).getValue())) {
  619.                     this.filterValues.get(i).setValue(value);
  620.                     break;
  621.                 }
  622.             }
  623.         }
  624.     }
  625.    
  626.     public void removeFilter(String name) {
  627.         if(this.filterNames != null) {
  628.             for (int i = 0; i < this.filterNames.size(); i++) {
  629.                 if(name.equals(this.filterNames.get(i).getValue())) {
  630.                     this.filterNames.remove(i);
  631.                     this.filterValues.remove(i);
  632.                     break;
  633.                 }
  634.             }
  635.         }
  636.     }
  637.    
  638.     @Deprecated
  639.     public void setFilterNames(List<DataElement> filterNames) {
  640.         this.filterNames = filterNames;
  641.     }
  642.     public List<DataElement> getFilterNames() {
  643.         return this.filterNames;
  644.     }
  645.     @Deprecated
  646.     public void setFilterValues(List<DataElement> filterValues) {
  647.         this.filterValues = filterValues;
  648.     }
  649.     public List<DataElement> getFilterValues() {
  650.         return this.filterValues;
  651.     }
  652.     public boolean hasAlmostOneFilterDefined() {
  653.         return this.hasAlmostOneFilterDefined(this.filterValues);
  654.     }
  655.    
  656.     private boolean hasAlmostOneFilterDefined(List<DataElement> filterValuesToCheck) {
  657.         if(filterValuesToCheck!=null) {
  658.             for (DataElement de : filterValuesToCheck) {
  659.                 if(!de.getType().equals("hidden") && de.getValue()!=null && !("".equals(de.value) || Costanti.SA_TIPO_DEFAULT_VALUE.equals(de.value))) {
  660.                     return true;
  661.                 }
  662.             }
  663.         }
  664.         return false;
  665.     }

  666.     public void setPageSize(int i) {
  667.         this.pageSize = i;
  668.     }
  669.     public int getPageSize() {
  670.         return this.pageSize;
  671.     }

  672.     public void setIndex(int i) {
  673.         this.index = i;
  674.     }
  675.     public int getIndex() {
  676.         return this.index;
  677.     }

  678.     public void setNumEntries(int i) {
  679.         this.numEntries = i;
  680.     }
  681.     public int getNumEntries() {
  682.         return this.numEntries;
  683.     }

  684.     public boolean isPageBodyEmpty(){
  685.         if(!this.dati.isEmpty()) {
  686.             // conto i campi non hidden
  687.             int nonHidden = 0;
  688.             for(int i = 0; i < this.dati.size(); i++){
  689.                 Object o = this.dati.get(i);
  690.                 if(o instanceof DataElement) {
  691.                     DataElement de = (DataElement) o;
  692.                     if(!de.getType().equals(DataElementType.HIDDEN.toString()))
  693.                         nonHidden ++;
  694.                 } else if(o instanceof List<?>) {
  695.                     List<?> v = (List<?>) o;
  696.                     for(int j = 0; j < v.size(); j++){
  697.                         Object o02 = v.get(j);
  698.                         if(o02 instanceof DataElement) {
  699.                             DataElement de = (DataElement) o02;
  700.                             if(!de.getType().equals(DataElementType.HIDDEN.toString()))
  701.                                 nonHidden ++;
  702.                         }
  703.                     }
  704.                 }
  705.             }

  706.             return nonHidden == 0; // dati presenti se c'e' almeno un elemento non hidden.
  707.         }

  708.         if(this.mode.equals(Costanti.DATA_ELEMENT_VIEW_NAME))
  709.             return false; // c'e' sempre qualcosa o bottoni o tasto edit

  710.         return (this.mode.equals(Costanti.DATA_ELEMENT_EDIT_MODE_DISABLE_NAME) || this.mode.equals(Costanti.DATA_ELEMENT_DISABLE_ONLY_BUTTON)); // bottoni invia/cancella

  711.     }

  712.     public boolean isMostraLinkHome() {
  713.         return this.mostraLinkHome;
  714.     }

  715.     public void setMostraLinkHome(boolean mostraLinkHome) {
  716.         this.mostraLinkHome = mostraLinkHome;
  717.     }
  718.    
  719.     public List<String> getLinkHomeLabels() {
  720.         return this.linkHomeLabels;
  721.     }

  722.     public void setLinkHomeLabels(String pre, String labelLink, String post ) {
  723.         this.linkHomeLabels = new ArrayList<>();

  724.         this.linkHomeLabels.add(StringUtils.isNotBlank(pre) ? pre : "");
  725.         this.linkHomeLabels.add(StringUtils.isNotBlank(labelLink) ? labelLink : Costanti.MESSAGGIO_SISTEMA_NON_DISPONIBILE_BACK_HOME);
  726.         this.linkHomeLabels.add(StringUtils.isNotBlank(post) ? post : "");
  727.     }
  728.    
  729.     public List<String> getDefaultLinkHomeLabels() {
  730.         List<String> l = new ArrayList<>();
  731.         l.add(Costanti.MESSAGGIO_SISTEMA_NON_DISPONIBILE_BACK_HOME_PRE);
  732.         l.add(Costanti.MESSAGGIO_SISTEMA_NON_DISPONIBILE_BACK_HOME);
  733.         l.add(Costanti.MESSAGGIO_SISTEMA_NON_DISPONIBILE_BACK_HOME_POST);
  734.         return l;
  735.     }

  736.     public String getCustomListViewName() {
  737.         return this.customListViewName;
  738.     }

  739.     public void setCustomListViewName(String customListViewName) {
  740.         this.customListViewName = customListViewName;
  741.     }
  742.    
  743.     public String getLabelBottoneInvia() {
  744.         return this.labelBottoneInvia;
  745.     }

  746.     public void setLabelBottoneInvia(String labelBottoneInvia) {
  747.         this.labelBottoneInvia = labelBottoneInvia;
  748.     }
  749.    
  750.     public String getLabelBottoneFiltra() {
  751.         return this.labelBottoneFiltra;
  752.     }

  753.     public void setLabelBottoneFiltra(String labelBottoneFiltra) {
  754.         this.labelBottoneFiltra = labelBottoneFiltra;
  755.     }

  756.     public String getLabelBottoneRipulsci() {
  757.         return this.labelBottoneRipulsci;
  758.     }

  759.     public void setLabelBottoneRipulsci(String labelBottoneRipulsci) {
  760.         this.labelBottoneRipulsci = labelBottoneRipulsci;
  761.     }

  762.     public boolean isShowAjaxStatusBottoneInvia() {
  763.         return this.showAjaxStatusBottoneInvia;
  764.     }

  765.     public void setShowAjaxStatusBottoneInvia(boolean showAjaxStatusBottoneInvia) {
  766.         this.showAjaxStatusBottoneInvia = showAjaxStatusBottoneInvia;
  767.     }
  768.    
  769.     public void setDisabilitaAjaxStatusBottoneInvia() {
  770.         this.showAjaxStatusBottoneInvia = false;
  771.     }

  772.     public boolean isShowAjaxStatusBottoneFiltra() {
  773.         return this.showAjaxStatusBottoneFiltra;
  774.     }

  775.     public void setShowAjaxStatusBottoneFiltra(boolean showAjaxStatusBottoneFiltra) {
  776.         this.showAjaxStatusBottoneFiltra = showAjaxStatusBottoneFiltra;
  777.     }
  778.    
  779.     public void setDisabilitaAjaxStatusBottoneFiltra() {
  780.         this.showAjaxStatusBottoneFiltra = false;
  781.     }

  782.     public boolean isShowAjaxStatusBottoneRipulisci() {
  783.         return this.showAjaxStatusBottoneRipulisci;
  784.     }

  785.     public void setShowAjaxStatusBottoneRipulisci(boolean showAjaxStatusBottoneRipulisci) {
  786.         this.showAjaxStatusBottoneRipulisci = showAjaxStatusBottoneRipulisci;
  787.     }
  788.    
  789.     public void setDisabilitaAjaxStatusBottoneRipulisci() {
  790.         this.showAjaxStatusBottoneRipulisci = false;
  791.     }
  792.    
  793.     public Dialog getDialog() {
  794.         return this.dialog;
  795.     }

  796.     public void setDialog(Dialog dialog) {
  797.         this.messageType = MessageType.DIALOG.toString();
  798.         this.dialog = dialog;
  799.         if(this.dialog != null) {
  800.             this.message = this.dialog.getTitolo();
  801.             this.messageTitle = this.dialog.getTitolo();
  802.         }
  803.     }

  804.    
  805.     public boolean isPostBackResult() {
  806.         return this.postBackResult;
  807.     }
  808.     public void setPostBackResult(boolean postBackResult) {
  809.         this.postBackResult = postBackResult;
  810.     }

  811.     public boolean isIncludiMenuLateraleSx() {
  812.         return this.includiMenuLateraleSx;
  813.     }

  814.     public void setIncludiMenuLateraleSx(boolean includiMenuLateraleSx) {
  815.         this.includiMenuLateraleSx = includiMenuLateraleSx;
  816.     }
  817.    
  818.     public DataElement convertiSearchInTextFilterMetadata() {
  819.         DataElement deName = new DataElement();
  820.         deName.setType(DataElementType.HIDDEN);
  821.         deName.setName(Costanti.SEARCH_PARAMETER_NAME_FAKE_NAME);
  822.         deName.setValue(Costanti.SEARCH_PARAMETER_NAME);
  823.        
  824.         return deName;
  825.     }
  826.    
  827.     public DataElement convertiSearchInTextFilter() {
  828.         String searchDescriptionCheck = this.getSearchDescription();
  829.         String searchLabelName = this.getSearchLabel();
  830.         boolean searchNoteCheck = this.isSearchNote();
  831.        
  832.        
  833.         DataElement deValue = new DataElement();
  834.         deValue.setType(DataElementType.TEXT_EDIT);
  835.         deValue.setName(Costanti.SEARCH_PARAMETER_NAME);
  836.         deValue.setLabel(searchLabelName);
  837.         deValue.setValue(searchDescriptionCheck);
  838.         deValue.setSize(Costanti.SEARCH_PARAMETER_DEFAULT_SIZE);
  839.        
  840.         if(searchNoteCheck && !searchDescriptionCheck.equals("")){
  841.             deValue.setNote(MessageFormat.format(Costanti.SEARCH_PARAMETER_NOTE, searchDescriptionCheck));
  842.         }
  843.        
  844.         return deValue;
  845.     }
  846.    
  847.     public boolean isPaginazione() {
  848.         return this.paginazione;
  849.     }

  850.     public void setPaginazione(boolean paginazione) {
  851.         this.paginazione = paginazione;
  852.     }

  853.     public List<DataElement> getComandiAzioneBarraTitoloDettaglioElemento() {
  854.         return this.comandiAzioneBarraTitoloDettaglioElemento;
  855.     }
  856.    
  857.     public void addComandoResetCacheElementoButton(String servletName, List<Parameter> parameters) {
  858.         if(parameters == null) {
  859.             parameters = new ArrayList<>();
  860.         }
  861.         // aggiungo parametri postback (come si fa in postback.js)
  862.         parameters.add(new Parameter(Costanti.POSTBACK_ELEMENT_NAME, Costanti.PARAMETRO_ELIMINA_ELEMENTO_DALLA_CACHE));
  863.         parameters.add(new Parameter(Costanti.PARAMETRO_IS_POSTBACK, "true"));
  864.         parameters.add(new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS_POSTBACK));
  865.        
  866.         this.addAzioneBarraTitoloDettaglioElemento(this.getComandiAzioneBarraTitoloDettaglioElemento(),
  867.                 DataElementType.IMAGE, Costanti.ICONA_RESET_CACHE_ELEMENTO_TOOLTIP, Costanti.ICONA_RESET_CACHE_ELEMENTO, servletName,parameters);
  868.     }
  869.    
  870.     public void addComandoVerificaCertificatiElementoButton(String servletName, List<Parameter> parameters) {
  871.         if(parameters == null) {
  872.             parameters = new ArrayList<>();
  873.         }
  874.         // aggiungo parametri postback (come si fa in postback.js)
  875.         parameters.add(new Parameter(Costanti.PARAMETRO_IS_POSTBACK, "true"));
  876.         parameters.add(new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS_POSTBACK));
  877.        
  878.         this.addAzioneBarraTitoloDettaglioElemento(this.getComandiAzioneBarraTitoloDettaglioElemento(),
  879.                 DataElementType.IMAGE, Costanti.ICONA_VERIFICA_CERTIFICATI_TOOLTIP, Costanti.ICONA_VERIFICA_CERTIFICATI, servletName,parameters);
  880.     }
  881.    
  882.     public void addComandoVerificaConnettivitaElementoButton(String servletName, List<Parameter> parameters) {
  883.         if(parameters == null) {
  884.             parameters = new ArrayList<>();
  885.         }
  886.         // aggiungo parametri postback (come si fa in postback.js)
  887.         parameters.add(new Parameter(Costanti.PARAMETRO_IS_POSTBACK, "true"));
  888.         parameters.add(new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS_POSTBACK));
  889.        
  890.         this.addAzioneBarraTitoloDettaglioElemento(this.getComandiAzioneBarraTitoloDettaglioElemento(),
  891.                 DataElementType.IMAGE, Costanti.ICONA_VERIFICA_CONNETTIVITA_TOOLTIP, Costanti.ICONA_VERIFICA, servletName,parameters);
  892.     }
  893.    
  894.     public void addComandoElementoCheUtilizzaServizioCondivisoButton(String iconaButton, String tooltipButton, String titoloModale, String bodyModale, String servletName, List<Parameter> parameters, String inUsoType) {
  895.         if(parameters == null) {
  896.             parameters = new ArrayList<>();
  897.         }
  898.        
  899.         ServletUtils.addAjaxButton(this.getComandiAzioneBarraTitoloDettaglioElemento(), DataElementType.IMAGE,
  900.                 iconaButton, tooltipButton, titoloModale, bodyModale, true, servletName, parameters, inUsoType);
  901.     }
  902.    
  903.     public void addComandoVisualizzaRuntimeElementoButton(String servletName, List<Parameter> parameters) {
  904.         if(parameters == null) {
  905.             parameters = new ArrayList<>();
  906.         }
  907.         // aggiungo parametri postback (come si fa in postback.js)
  908.         parameters.add(new Parameter(Costanti.PARAMETRO_IS_POSTBACK, "true"));
  909.         parameters.add(new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS_POSTBACK));
  910.        
  911.         this.addAzioneBarraTitoloDettaglioElemento(this.getComandiAzioneBarraTitoloDettaglioElemento(),
  912.                 DataElementType.IMAGE, Costanti.ICONA_VISUALIZZA_RUNTIME_ALLARME_TOOLTIP, Costanti.ICONA_VISUALIZZA_RUNTIME_ALLARME, servletName,parameters);
  913.     }
  914.    
  915.     public void addComandoInUsoElementoButton(String servletName,
  916.             String titolo, String id, String inUsoType,
  917.             String tooltip, String icon, String headerRiga1,
  918.             Boolean resizable, Boolean draggable) {        
  919.         ServletUtils.addInUsoButton(servletName, this.getComandiAzioneBarraTitoloDettaglioElemento(), DataElementType.IMAGE, titolo, id, inUsoType,
  920.                 tooltip, icon, headerRiga1,
  921.                 resizable, draggable, true);
  922.     }

  923.     public void addComandoAggiornaRicercaButton(String servletName, List<Parameter> parameters) {
  924.         if(parameters == null) {
  925.             parameters = new ArrayList<>();
  926.         }
  927.         // aggiungo parametri postback (come si fa in postback.js)
  928.         parameters.add(new Parameter(Costanti.POSTBACK_ELEMENT_NAME, Costanti.PARAMETRO_AGGIORNA_RICERCA));
  929.         parameters.add(new Parameter(Costanti.PARAMETRO_IS_POSTBACK, "true"));
  930.         parameters.add(new Parameter(Costanti.DATA_ELEMENT_EDIT_MODE_NAME, Costanti.DATA_ELEMENT_EDIT_MODE_VALUE_EDIT_IN_PROGRESS_POSTBACK));
  931.        
  932.         this.addAzioneBarraTitoloDettaglioElemento(this.getComandiAzioneBarraTitoloDettaglioElemento(), DataElementType.IMAGE, Costanti.ICONA_AGGIORNA_RICERCA_TOOLTIP, Costanti.ICONA_AGGIORNA_RICERCA, servletName,parameters, false);
  933.     }
  934.    
  935.     private void addAzioneBarraTitoloDettaglioElemento(List<DataElement> e, DataElementType deType, String tooltip, String icon, String servletName, List<Parameter> parameters) {
  936.         this.addAzioneBarraTitoloDettaglioElemento(e, deType, tooltip, icon, servletName, parameters, true);
  937.     }
  938.    
  939.     private void addAzioneBarraTitoloDettaglioElemento(List<DataElement> e, DataElementType deType, String tooltip, String icon, String servletName, List<Parameter> parameters, boolean contextMenu) {
  940.         DataElement de = new DataElement();
  941.         de.setType(deType);
  942.         de.setToolTip(tooltip);
  943.         if(parameters != null && !parameters.isEmpty()) {
  944.             de.setUrl(servletName, parameters.toArray(new Parameter[parameters.size()]));
  945.         } else {
  946.             de.setUrl(servletName);
  947.         }
  948.         de.setIcon(icon);
  949.         de.setContextMenu(contextMenu);
  950.        
  951.         e.add(de);
  952.     }

  953.     public boolean isInserisciSearch() {
  954.         return this.inserisciSearch;
  955.     }
  956.    
  957.     public void nascondiTextFilterAutomatico() {
  958.         this.setInserisciSearch(false);
  959.     }

  960.     public void setInserisciSearch(boolean inserisciSearch) {
  961.         this.inserisciSearch = inserisciSearch;
  962.     }
  963. }