how to create group of gwt Order list - gwt

Hi,
My goal is to create a list of items in GWT similar to how it is done in HTML using ordered and unorderd lists. Can someone explain to me how this can be achieved in GWT?
Thanks!!

you can use the dom API in com.google.gwt.dom.client which has a syntax very close from the JavaScript one:
for (String listItem : listData) {
LIElement liElement = Document.get().createLIElement();
liElement.setInnerText(step);
this.olElement.appendChild(liElement);
}
this example simply add the list item build from the listData List end append them in the ordered list. I used UiBinder to get the olElement so you have to get a root element somewhere (Document has a method getElementById) and add your Element to it.

Related

How to remove a piece in a string

So I am making a quest system, and I want to randomly choose a quest, but i dont want it to choose the same one again.
Here is the piece on code for the string.
I cant find any good answer.
This is a more simple line of code.
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
3 methods come to mind:
Convert to a List and call Remove().
Write null into the array after having read the quest and when selecting a quest, always search for the next suggestion if null was selected.
Keep a separate data structure like a HashSet<int> where you add the index in the array whenever a quest has been used. Then check for Contains on your ID when selecting.
You really ought to use lists if you want to dynamically add/remove elements from your set.
Instead of:
string[] QuestChoose = new string[] {"Quest1", "Quest2", "Quest3"};
try using:
List<string> QuestChoose = new List<string> { "Quest1", "Quest2","Quest3"};
You can add elements by calling QuestChoose.Add("Quest4");
Or remove an element by calling: QuestChoose.Remove(ItemNumber);
Where as "ItemNumber" is the index of the string you want to remove. For example; Calling QuestChoose.Remove(0); will remove the first item in the list, which in this case would be "Quest1"

How to retrieve the rows which are selected in the list report page of smart templates

This is the List Report type of Smart Template application
Here I have selected 2nd and 5th row, I also have a button named Send Requests in the section part which is highlighted. If I click this button it calls a javascript controller function which is defined in the extensions of the application. In this js function how can I retrieve the selected rows that are selected?
I have enabled the checkboxes in this page by mentioning this code
"settings": { "gridTable": false, "multiSelect": true } in the manifest.json
As it was recommended by this link https://sapui5.netweaver.ondemand.com/#docs/guide/116b5d82e8c545e2a56e1b51b8b0a9bd.html
I want to know how can I retrieve the rows which got selected?
There is an API that you can use for your use case. It is described here: https://sapui5.netweaver.ondemand.com/#docs/guide/bd2994b69ef542998becbc69ab093f7e.html
Basically, you just need to call the getSelectedContexts method. Unfortunately you will not be able to really get the items themselves, only the binding contexts (which point to the data entities which are selected). Excerpt from the documentation:
After you have defined a view extension, you can access and modify the
properties of all UI elements defined within these extensions (for
example, change the visibility). However, you cannot access any UI
elements that are not defined within your view extensions.
In this type of table there is way.
var myTable=sap.ui.getCore().byId("your table id");
get all rows:
var myTableRows=myTable.getRows();
now get selected Indices
var selectedIndeices=myTable.getSelectedIndices(); //this will give you array of indeices.
now run loop on indeices array. And get particular row item;
// get binding path
var bindingpath=myTableRows[2].getBindingContext().sPath; // this will return eg:"/ProductCollection/2"
// now get Binding object of that particular row.
var myData=myTableRows[2].getModel().getObject(bindingpath); // this will return binding object at that perticular row.
// once your loop is over in the end you will have all object of selected row. then do whatever you want to do.
If you use smart template create an extension.
This is the standard event befor the table is rebinding:
onBeforeRebindTableExtension: function (oEvent) {
this._table = oEvent.getSource().getTable();
}
In your action function (or where you want) call the table and get the context :
this._table.getSelectedContexts();

Nested Multifield or Multifield with in Multifield in CQ5

Wanted to a build a nested multifield dialogue in cq5.
My requirement is to build a single multified component with
Title
LinkText
Linkpath
ImageUpload
with in this multifield ,I wanted to have linktext as another multifield.
Note:
.I was able to create titile,linktext,linkpath,imageupload as multifield,but couldnt make linktext as another multifield inside a multifield. I am new to cq5 dev,Kinldy Suggest if there are any other approach.
I believe the only way to do this is to write your own widget. I have accomplished this but am unable to share the code. If you want you can check out this open source library I have been working on building out at https://github.com/Velir/AEM-Toolbox. The StucturedMultiList widget may suit your needs.
An example how to implement a custom widget as described by Chris Leggett can be found at:
http://cq.shishank.info/2011/12/19/multifield-with-custom-xtype/
How I've stored the value is in the format:
[item1|item2]
Using a bit of logic you can then extract a link text and url but the third value seems to step into bad practice if you're using this format, but the style of storing this information will be the same. Maybe you could store the information as JSON, but I haven't personally seen an implementation of this.
Hope that helps.
This will involve customizing the multifield js and creating custom xtypes by extending composite field. Most of the part of nesting custom multifields is same as creating a single custom multifield.
The inner multifield will return a comma separated String on getValue, this will have to be concatenated with other fields of outer multifield separated by a delimiter. The set value of inner multifield will expect a string array, for this you will have to modify the multifield js of inner multifield and override the set value method to take the comma separated string and split into an array.
The outer multifield will also have to be updated on change of inner multifield content.This can be done by calling the update method right after updating inner multifield(reference to the outer multifield can be obtained through findParentBy method)
The end result will look like this
String array
[0] : a-outer-field1<#->a-outer-field2<#->a-1-inner-field1<#-#>a-1-inner-field2<#-#>,a-2-innerfield1<#-#>a-2-innerfield2<#-#><#-*>
[1] : b-outer-field1<#->b-outer-field2<#->b-1-inner-field1<#-#>b-1-innerfield2<#-#>,b-2-innerfield1<#-#>b-2-innerfield2<#-#><#-*>
Check out this link http://cq5tutorials.blogspot.com/2014/04/cq5-multifield-in-multifield.html

Dynamic list of checkboxes

I have a list of AccessPrivileges and I would need to create a form with a dynamic list of checkboxes, however I cannot find a solution inside the documentation.
Assuming you have the following
class AccessPrivilege(dataType:String, description:String)
object AccessPrivilege {
val privileges:Seq[AccessPrivilege] = ....
}
I would need to generate a binding so that , in my form I can:
Have a checkbox whose label is the description
Being able to retrieve the list of selected checkboxes as a List of String and not as a List of boolean.
I can't find among the form helpers what I need, because the checked returns a boolean, while I need to "collect" the selected checkboxes...

Editing the data in a List in a Dashcode app

I’m writing a Dashcode app that contains a list. I’d like to populate this list with my data, but when I define the function
function populate_list()
{
var list = document.getElementById("list");
list.setDataArray(test_data);
list.reloadData();
}
I get an error; I think the reason is that list in this context is a normal HTML ul element and not an instance of the fancy DC.List class that Apple has defined. How can I access my list in such a way that I can use its methods and access its properties?
In dashcode under library/code there is an example titled 'List Data Source'. You will also need to alter the list object datatype to dynamic and then select your datasource from the dropdown list.
It turns out that I wanted to do
var list = document.getElementById("list").object;