Passing Arraylist from fragment to Activity - android-activity

I have got an arraylist with values in a fragment and I want to return that arraylist to the activity to display the contents of the list. What shall be the easiest approach?

Related

Internal mechanism of TreeViewer for updte

I am new to SWT and RCP I am trying to use TreeViewer.
By referring to some documents, I came to know there is method:
treeViewer.Updte(Object , Properties).
I need to know how SWT figure out which data is for which field.
The method is called update:
public void update(Object element, String[] properties)
Here element must be an object that equals one of the objects returned by the content provider for the tree.
If you have called
treeViewer.setUseHashlookup(true);
then a hash table (similar to HashMap) is used to find the tree element corresponding to the element. Otherwise the tree is just searched exhaustively to find the element.

how can I get an array of all objects in w2ui

I am trying to subsequently manipulate the menus and tabs of a w2ui application.
In order to implement a generic solution, I added an additional attribute (zndesktop) to the related elements. Now I am looking for a generic method which gives me an array of all objects having this attribute.
Of course, I can hardcode such a query. But I am asking if there is an generic approach (for example w2ui.objects) which would return an array of all UI objects created for the application (recursive search)
w2ui objects are actually stored directly in the global w2ui object using their name, until you destroy them.
Example: if you create a grid with
$('#grid').w2grid({
name: 'my_grid',
...
});
Then you can access it with w2ui.my_grid or w2ui['my_grid'].
Of course you can also iterate the w2ui object (or rather its properties) just like any other JS object.

How to write variable of activity that contains fragment class from inside current Fragment?

I have an activity with indefinite number of fragments. Inside fragments there is a variable that need to access in the activity to call an intend from activity bar correctly.
But only the variable of the current fragment is on screen.
This is because the call depends of the fragment you are.
Due to fragment manager creates three fragment at a time can't write a variable calling from inside fragment because i don't know who is the last that writes variable.
Need to identify the fragment is displayed.
I tried from inside to control visibility overriding setUserVisibleHint(boolean b) and write variable when true but same happends. not guaranteed that the current fragment is the last writting.
I also tried getting the current fragment from activity to call fragment method and get this variable. But is difficult to identify current fragment. I tried this:
getsupportFragmentManager()
.findFragmentByTag("android:switcher:"+R.id.myViewPager+":"+myViewPager.getCurrentItem()).getVariable();
But have null Pointer Exception.

Spring List Binding in Form

I'm trying to bind a list/arraylist/hashmap/etc of custom objects to my form in JSP using Spring. Right now, the controller creates a Map of the two lists (Boolean list and custom object list) in referenceData(), and provides it to the form which uses those values to populate the fields. The values are initialized from a MySQL database using Hibernate, and all that works fine. The list is a known length before the form is initialized, so that part is easier. Now what I'd like to do is correctly bind those objects in the form, so that when there are changes made, I can detect that in onSubmit() (or wherever is appropriate), and update the database accordingly. I can't seem to bind them correctly in the form so that I can see changes made. I tried just using a list of the form fields as the model, but even that wasn't working correctly. Do I just need to inject the list in a particular way? Any ideas or examples here? Any help would be greatly appreciated.
UPDATE: At Ralph's request here is the solution I used:
In my data object class, I lazy loaded a map using MapUtils.lazyMap(), with a String key and other custom object value. The other custom object is just a class that contains List<String> and getters/setters. In the corresponding .jsp file, I just nest several loops to loop through the keys first using loop.current.key and then loop2.current.value.paramsList to loop through the values for that key. This was not really what I asked for in my original post, as I was looking for a more general solution, and the lazy loading pointed me in the right direction.
In Spring 2 you need a special List in your Command object, that is able to grow if one add the x-th element event if the list has not this size yet.
One way to do that is to use LayzList decorator from commons-collections.
#Override
protected Object formBackingObject(final HttpServletRequest request)
throws Exception {
List<PosterSelectionRow> posterSelectionRowList = LazyList.decorate(
new ArrayList<PosterSelectionRow>(),
new PosterSelectionRowListFactory());
return new PosterSelectionCommand(posterSelectionRowList);
//PosterSelectionCommand contains a list of selected poster rows
}
private static class PosterSelectionRowListFactory
implements org.apache.commons.collections.Factory {
/** Invoked if the list need a new element */
public Object create() {
return = new PosterSelectionRow();
}
}
When I remember right, there is a way without that Factory stuff, but I am not sure.

Gwt iterate on text controls in a Composite

Can one iterate over all the textbox controls defined in a composite widget?
As in I need to extract values of all textboxes to check if they exist - the textboxes should have some data in them.
So I was hoping to have a method like:
for(Widget w: this.getChildren)
{
//if widget is a textbox - check value
}
Composite class does not have a method like getChildren neither a method where I can get elements of a given class - or name and if I get all the elements using NodeList then I need to recursively go until I find a textbox. Is there a more appropriate way to do this?
As the author of the Composite subclass, you can enable this kind of behavior by implementing HasWidgets (or, more specifically, something like getWidgetIterator()).
There's no way to do this for an arbitrary Composite.