Magnolia CMS: Duplicate data validation in spring blossom paragraph - validation

I have a paragraph defined in spring blossom which consists of edit,file, select and date controls. Now I want to allow only one data entry for each date in that page, i.e. date field should be unique. How can I do duplicate data validation based on date field in DailogValidator?
Thanks,
Rupali

In the validator you have access to the content and can iterate through it looking for a paragraph having the same date.
You can get the content either from MgnlContext.getAggregationState() or by adding DialogCreationContext as an argument to your validator method.
When iterating the content of the page you should be looking at nodes of type ContentNode having the same paragraph. The paragraph assigned to the node is set in the nodes MetaData as 'template'.
This code does basically the same thing but you might want to change it from searching by class to searching for name instead.
Hope that helps!

Related

Google Sheets data validation different for each row

For my current project, I'm making a sheet that lets me keep track of my D&D characters. I use data validation to remind me what all the options are for various stats, with the information being kept in a separate "RefTables" sheet. Creating a data validation for selecting a character class is very easy, since there are only 14 classes total. What I'm having trouble with is the 'subclass' column. After you choose the character class, you get to choose your specialization, or 'subclass'. This differs depending on the character class you chose.
Right now I can do the proper data validation for each cell individually. In my ref tables sheet, I have a section where it will grab the character class value and put all the 'subclass' options into a row. I can then use data validation in that specific cell to grab the subclass row. This works, but is tedious to do for every single cell.
The formula I would love to put in the range section is
=INDIRECT(CONCATENATE("RefTables!Q",ROW(),":AJ",ROW()))
which appends the row number with the appropriate columns so each row automatically gets its own subclass row (EX: RefTables!Q3:AJ3, RefTables!Q21:AJ21, etc.). I've seen solutions for Excel, but I'm using Google Sheets so I can share this document more easily with friends.
tldr; How to use data validation in Google Sheets that is slightly different for each row
unfortunately, this is possible to achieve only the manual way setting it up for every single cell/row. Google Sheets' Data validation does not support injecting CSVs via formula.

JMeter - Need to submit POST data but I only wish to modify a single field

I'm running some JMeter tests for editing a field. If I use the JMeter HTTP(S) Test Script Recorder, I can get an accurate representation of the page and edits I made.
It creates a HTTP POST request with a parameter for every field, checkbox and dropdown on the page. I only really care about modifying ONE of them.
My problem is I can't just remove all the other parameters from the POST data because the page interprets this as if I removed all of them from the page (and then complains that there's missing data). So I'm left with trying to obtain the current values for the remaining editable fields and checkboxes so that I can re-submit them when I only want to modify a single field.
For an example, imagine I'm submitting some user data with fields for Name, Email and Address. I want to change the name by adding a 1 to the end of it and leave the other two fields as they are.
My thoughts for accomplishing this:
1) Use XPath to try to get the values shown on the page, store them all in variables and re-submit them in the post request. This is messy and also very difficult as the page is shown in a pop-up window, adding to the complexity of it.
2) Query the database for all the information and re-submit it. Seems like a lot of overhead, plus the data isn't freely available .. I'd rather not have to try to do this.
3) Use some other element of JMeter I'm not aware of to obtain the specific element data from the page. Maybe some listener I haven't figured out yet? If I could pull the parameters from the page and save them, that would be VERY convenient.
4) Somehow submit a POST request with only one field, specifying that I do not wish to clear out the remaining fields, I just want to leave them alone. I will freely admit that I am not super familiar with web applications so there may be a very obvious reason as to why this can't be done (or it's dependent on how its handled by the back-end of the application).
Thoughts?
From the whole post, I understand that you want to parameterise a field, where each time different value will be passed.
If my understanding is correct, the answer lies in CSV Dataset Config, where you can pass the values from a CSV file.
From your Example:
For an example, imagine I'm submitting some user data with fields for
Name, Email and Address. I want to change the name by adding a 1 to
the end of it and leave the other two fields as they are
To achieve this:
Steps to follows:
Create a csv file. fill the names as follows:
names
name1
name2
name3
name4
names is the column header and remaining are values.
Add CSV Dataset Config to your Test Plan.
Specify the file path.
replace the value in the name field in HTTP Post request as ${names}. that's it.

GWT (smartgwt) grid sort selected records top

I have a grid where the user can select records via checkbox in front of every record. Now I have a requirement to sort the records based on their selection, so that all selected records should be placed top, followed by the not selected ones.
Is there any standard function to achieve this? As an alternative I thought of saving the selection state as an attribute on every record and sort based on the attribute.
The code for the column is:
gridRealmDt.setSelectionType(SelectionStyle.SIMPLE);
gridRealmDt.setSelectionAppearance(SelectionAppearance.CHECKBOX);
I try to describe the code I use as the affected code is deeply nested in our own framework classes.
gridRealmDt is a subclass of smartgwt ListGrid. In my Dialog a create an instance of the grid which creates an instance of a database bound datasource. When the dialog is loaded the records are fetched from the database and after that a registered an dataArrivedHandler where I select the records which match records from another table.
I tried to place the selection attribute in an extra field and use that for sortig before my other sort criteria, but this does not work. Here is the code for the field I am using.
ListGridField txtSelected = new ListGridField(SELECTED, "");
txtSelected.setHidden(true);
txtSelected.setSortByDisplayField(true);
txtSelected.setCanSortClientOnly(true);
When I do not set the canSortClientOnly property the order by is sent to my database resulting in an error, as the table does not contain that field, so I set the property. Now I get following error
Removing field from the sort Specifier array because it specifies canSort Client Only: true and all data is not yet client-side.
I also tried to use a sortNormilizer on the Name field which is my main sort criteria, but the normalizer is called before the selection value is set to the record.
record.setAttribute(CARealmDS.SELECTED,selected ? "a" : "b");
I also cannnot find a way to call the normalizer when selection changes.
Currently we are using Smart GWT Version 6.0p.
I don't think there is any standard function. Just use grid store update. Place checked items first.

XPath: Forms with Unique IDs

I am trying to use XPath as part of a data scraper in order to scrape random comments from reddit for a project. The problem is, the comment forms have unique IDs that change on every page and within comment indent levels. I'm not sure how to make XPath target all of the comment fields with these different IDs.
An example is shown below:
//form[#id='form-t1_cj8cyupxa3']/div
//form[#id='form-t1_cj8e0iyx6w']/div
If there is some pattern to the id then try e.g. //form[starts-with(#id, 'form-')]/div

Queries with NSValueTransformer

1.In my application there is a requirement to display certain value (among the 3 different values) in each row of the table column,the value to be displayed in each row can be decided by checking the values of two different model key paths.
This i tried to implement using bindings,where i used "Display pattern Value1 with one key path and custom value transformer class" and "Display pattern Value2 with other key path and same value transformer".But i am not getting desired output value from the transformer class.Can anyone please help me in resolving this issue.
2.In the other application there is a table view with 3 columns,where the first column displays the complete word,second column displays the prefix of that word and the third column displays the suffix of that word.
I implemented this requirement using bindings and two custom value transformer classes.One for getting the prefix of the word(prefixExtractor) and the other for getting the suffix of the word(suffixExtractor).Can anyone suggest me how can i implement this requirement using only one custom value transformer class so that it optimizes my code.
Thanks in advance.

Resources