I'm using Struts and I have a multiple html:select like this:
<html:select styleClass="selectedFichier" multiple="multiple" property="listFichiersSelected">
<html:optionsCollection property="fichiers" value="id" label="nom"/>
</html:select>
I use the Jquery Chosen plugin to select 1 or more files and it gives me an array of Strings.
$(".selectedFichier").chosen({ disable_search: false, allow_single_deselect: true, placeholder_text_multiple: " ", width: "400px" });
But when I want to make a modification and therefore remove all my files from my multiple list, the first index of my string array does not want to be removed so I always have one left when I validate my form.
Here is the code of my actionController for my string array when I validate:
// On récupère la liste des fichiers sélectionnés
ArrayList<FichierUnite> fichiers = new ArrayList<FichierUnite>();
for (int i=0; i<dataBean.getListFichiersSelected().length ; i++) {
String codeFichier = dataBean.getListFichiersSelected()[i];
Fichier fichier = exploitationAd.getFichier(Integer.parseInt(codeFichier));
if (fichier != null) {
FichierUnite fichierUnite = new FichierUnite();
fichierUnite.setUnite(dataBean.getUneUnite());
fichierUnite.setFichier(fichier);
fichiers.add(fichierUnite);
}
dataBean.getUneUnite().setListfichiers(new HashSet<FichierUnite>(fichiers));
Related
I have a spreadsheet, in which I need the script to fetch, over two columns, two pieces of information. And when that's true, I add a formula that adds "1 day" into a third column.
I can make the conditionals run individually. But when I put both, they don't work.
function fillColADia() {
var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Afazeres');
var dataA = s.getRange("H1:H").getValues();
var dataB = s.getRange("A1:A").getValues();
for(var i=0; i<dataA.length; i++) {
for(var j=0; j<dataB.lenght; j++) {
if (dataB[j][0] == false) {
if (dataA[i][0] == 'Zenon') {
s.getRange(i+1,3).setValue("+1");
}
}
}
}
}
And I also don't know how to add the "add 1 day" formula to the end.
Thanks a lot for the help.
COPY FILE with dummy data
Faaala! Something along these lines as food for thought!
...although I'm certain there are more performant ways to accomplish it:
function fillColADia() {
var s = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Page1');
var data = s.getRange("A1:H").getValues();
for (var a = 0; a < data.length; a++) {//Percorre cada linha do intervalo
if (data[a][0] == false && data[a][7] == 'Zenon') {//Aplica critérios
let date = data[a][2];//Pega a data daquela linha
date1 = Utilities.formatDate(addDays(new Date(date), 1), Session.getTimeZone(), "dd/MM/yyyy");//Formata o objeto data, usando a função abaixo para incrementar o dia
date2 = Utilities.formatDate(addDays(new Date(date), 1), Session.getTimeZone(), "dd/MM/yyyy HH:mmss");
s.getRange(a + 1, 3).setValue(date1);//Põe a data de volta
s.getRange(a + 1, 4).setValue(date2);//Põe a data de volta
}
}
}
//GERA DATAS INCREMENTANDO OS DIAS
function addDays(date, days) {
var result = new Date(date);
result.setDate(result.getDate() + days);
return result;
}
I got a sheet with merged cells and in those merged cells, a script write its results.
When I copy this result in the merged cells, it gave me multiple spaces at the end.
Like : Result #1________ (« _ » represent invisible space)
When I put the same result in a normal cell (not merged), it doesn’t put any space at the end.
Result #1
I tried multiple cell format (Center aligned, left aligned, etc.) but nothing changed.
Do you have any idea why ?
Thanks !
EDIT : add script
Script
function Devise() {
const sheetName = "Missions";
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
var Devise = "";
var NombreMission = "";
var NomOperateurs = "";
if(sheet.getRange("H2").getValue()=="") { // Si la mission 7 est vide
NombreMission = 6; // On compte seulement 6 missions
} else {
NombreMission = 7; // Sinon on compte 7 missions
}
for (i = 1; i < NombreMission+1; i++) { // Boucle FOR pour NombreMission missions
if(sheet.getRange(2,i+1).getValue()=="") { continue; } // Si la mission est vide, on la passe
Devise = Devise + i + "/";
l = 0; // Variable pour indiquer "Rien" si personne à placer dans la mission
NomOperateurs = ""; // Reset les noms pour la mission d'après
for (j = 1; j < 27+1; j++) { // Boucle FOR pour tous les opérateurs
if(sheet.getRange(j+2,i+1).getFontWeight() == 'bold') { // Vérifie si la case est en gras
/*if(i!=NombreMission) { // Tant qu'il ne s'agit pas de la dernière mission ...
Devise = Devise + sheet.getRange(j+2,1).getValue() + " "; // ... on affiche les opérateurs
}*/
NomOperateurs = NomOperateurs + sheet.getRange(j+2,1).getValue() + " ";
l = l + 1; // On compte les opérateurs
}
} // Fin Boucle FOR opérateurs
if (l==24) { // S'il y a tous les operateurs sur une mission...
Devise = Devise + "ALL OPs! " // ... On affiche "All Op!"
} else if (i==NombreMission && l!=0) { // Sinon s'il s'agit de la dernière mission et qu'il reste des opérateurs à placer...
Devise = Devise + "Autres + Epic "; // ... On indique qu'il s'agit du reste et des épiques
} else if (l==0) { // Sinon s'il n'y a aucun opérateurs à placer...
Devise = Devise + "RIEN " // ... On indique "RIEN"
} else { // Sinon ...
Devise = Devise + NomOperateurs; // ... On affiche les opérateurs
}
} // FIN BOUCLE FOR NombreMission
if(NombreMission==6 && Devise!="") { Devise = Devise + "7/!NOTHING!";}
sheet.getRange("K13").setValue(Devise);
}
Your problem is related to the data you copied and the way that you copied it as pasting text in merged cells doesn't create any new lines.
Also, an important thing to keep in mind is that CTRL+ENTER creates the mentioned space also known as a line break.
So, for example, if this cell contains the text Text + line break:
And the text from the above cell is copied and pasted into a merged cell it will look like this - which is the same outcome as the one that you have mentioned:
But if you paste the same text to a simple cell, it will look like this:
This is essentially because the line break will signify the start of a new cell.
For example, this cell contains this text with line breaks:
After the text is copied and pasted into a different cell, this is how it will actually be pasted as:
In order to solve your issue, I suggest you to copy only the text needed and if possible to avoid using any line breaks.
Reference
Edit and Format a Spreadsheet.
Encountering the same issue.
I have a merged cell with text. If I select the cell and paste it into notepad, It includes quite a lot of white space.
I've checked and if the merged cell spans two rows, the white space includes a line break.
If the merged cell spans one row but two columns, the white space does not include a line break.
If I have a single cell and have it take its value from the mered cell "=A1", the text does not include the white space.
So the addition of the whitespace is definitely the result of having a merged cell.
There are a lot of questions about select2 doubling values, and many of them don't have accepted answers.
On the surface everything looks fine but when I delete a token it's still sending it in params.
Checking the values of the input (which select2 is hiding)
Prior to initializing select2
$('#language_list').val() //=> "english spanish italian"
After init
$('#language_list').val() //=> "english spanish italian,english,spanish,italian"
// It's clearer what's going on like this.
// And I don't know if it's significant but tokenSeparators: [",", " "]
$("#user_language_list").select2("val") //=> ["english spanish italian", "english", "spanish", "italian"]
Lots of issues are coming up like when the form repopulates after an error I'll have
$('#language_list').val() //=> "english-spanish-italian english spanish italian,english,spanish,italian"
Hidden in my input which I have to address on the backend.
What worked was cleaning the value before sending your data to the callback
You'll probably recognize this as basically the code from the docs.
initSelection: function (e, callback) {
var tags = e.val().split(/, |,| /);
for (var i = 0; i < tags.length; i++) {
var tag = tags[i].trim();
tags[i] = {id: tag, text: tag};
}
callback(tags);
}
But you just need to clean the val
initSelection: function (e, callback) {
var tags = e.val().split(/, |,| /);
e.val("")
for (var i = 0; i < tags.length; i++) {
var tag = tags[i].trim();
tags[i] = {id: tag, text: tag};
}
callback(tags);
}
I am trying to use jquery mobile, I want to retrieve the list of checked box. Here is my code to populate the list of checkbox:
for( var i=0; i<results.rows.length; i++ ) //Remplir tableau liste des identifiants étapes
{
$('#lbtn2').append("<input type='checkbox' value="+
results.rows.item(i).Phrase+
" name = "+results.rows.item(i).QuotationParDefaut+
" id="+results.rows.item(i).idPhrase+" />");
$('#lbtn2').append('<label for='+
results.rows.item(i).idPhrase+'>'+
results.rows.item(i).Phrase+'</label>');
}
And here is the code that allows to retrieve the list of selected labels.
$("#lbtn2 input:checked").each(function()
{
tab_phrase_selectionner[j] =
$("label[for='" + ( $(this).attr("id") ) + "']").text();//Pour le fichier A1.js
j++;
});
The problem is that if I select six checkboxes it returns only 3 checkboxes. Anybody have an idea about this problem?
def results = {
def results = [:]
def conferences = Conference.list() // lista das conferencias
String [] conf_origin // array de strings da indexação da classe
String [] conf_search = params.conferenceName.split() // array de strings palavras da pesquisa
boolean test // teste double for
conferences.each{
conf_origin = "hi i'm john".split() // indexação
//conf_origin = "aveiroa".split()
OUTER: for(int i = 0; i< conf_origin.length; i++){
for(int j = 0; j< conf_search.length; j++) {
if(conf_origin[i] == conf_search[j]){
test = true
results.put(it.id, it)
break OUTER;
}
}
}
}
return [results : results]
}
Hey i am having this problem. If i return: "[conferences: conferences]" my gsp sucessfully do what i want. Altought, when i return '[results: results]' which is suposelly a filtered map of conferences, the folowing error is displayed and i cant figure it out why:
Exception Message: No such property: yearCount for class: java.util.LinkedHashMap$Entry
PS. Basically, i have
String [] conf_origin ---> which is a String array of words
String [] conf_search ---> which is a string array of introduced words in search bar.
Then i compare both arrays, and if there's one match, i break the for and add that conference object to results.
conferences is a List (of Conference, but it's untyped in Groovy), and results is a Map. You need either to:
make it a List of Conference
or return [conferences: results.values()]
or adjust your GSP page to iterate over a Map.
Note that conferences is a variable name your GSP code relies onto.