We can have SimpleType values like SimpleType.INTEGER, SimpleType.STRING in a CompositeData. I want nested composite type i.e. a composite type containing another composite type.
I am using the code below to perform that. But it does not displays the CompositeData in the JConsole. What it displays for me is the metadata of the CompositeData and not the real data.
Please tell me a way to counter the problem.
CompositeType type = new CompositeType("My Type", "My Type", new String[]{"item1", "item2"}, new String[]{"item1", "item2"}, new OpenType[]{SimpleType.STRING, SimpleType.STRING});
CompositeData data = new CompositeDataSupport(type, new String[]{"item1", "item2"}, new String[]{"item value 1", "item value 2"});
CompositeType compType = new CompositeType("compData", "compData", new String[]{"compItem1"}, new String[]{"compItem1"}, new OpenType[]{type});
CompositeData compData = new CompositeDataSupport(compType, new String[]{"compItem1"}, new Object[]{data});
Have you tried Java Mission Control (shipped with 7u40+) instead of JConsole. I believe it's better at displaying more complex data.
It's much easier to handle composite types with MXBeans. You should start there, if you can. You can return more complex objects from methods and attributes; as long as they follow the MXBean rules, you'll get all of the complex type handling for free.
Related
I am using System.Linq.Dynamic.Core v 1.2.24 to create a dynamic select statement when querying SQL Server via Entity Framework. This is sitting behind a GraphQL API and the intention is to make the database query as efficient as possible - only query the database for the requested columns.
I have the projection working for the type being enumerated but that type has a child property which also needs projection.
I have created a simple Fiddle to demonstrate this .
https://dotnetfiddle.net/nvU7DB
In the example I am querying a Person collection and Person has a property Address. I am successfully projecting the Person properties but can't figure out how to project the Address properties. I have not been able to find any examples of this.
This dynamic linq string will bring back all properties of Address:
"new Person(Id, FirstName, Address)"
but I want to do a projection on Address to just populate Id and City for example.
I was thinking the string might look like this
"new Person(Id, FirstName, new Address(Id, City)"
but this results in "Unhandled exception. Type 'Address' not found (at index 37)"
Without the 'new':
"new Person(Id, FirstName, Address(Id, City))"
which results in "Unhandled exception. No property or field 'City' exists in type 'Person' (at index 38)".
To clarify what I'm trying to do, this is what the projection would look like in C# code:
var projectedPeople = people.Select(
e => new Person() {
Id = e.Id,
FirstName = e.FirstName,
Address = new Address(){
Id = e.Address.Id,
City = e.Address.City
}
});
Any help or insights would be appreciated.
For anyone picking this up later, the solution was as follows
string dynamicSelect = "new Person(Id, FirstName, new Address(it.Address.Id, it.Address.AddressLine1, it.Address.City) as Address)";
ParsingConfig parsingConfig = new ParsingConfig(){ResolveTypesBySimpleName = true};
IEnumerable result = (IEnumerable)peopleQueryable.Select(parsingConfig, dynamicSelect);
i created 4 variables namely, "id", "name", "address", "age"
why does the value duplicates whenever i try intent.putextra
Context context = view.Context;
Intent intent = new Intent(context, typeof(activity4));
intent.PutExtra(activity4.id, joblist[position].id);
intent.PutExtra(activity4.name, joblist[position].name);
intent.PutExtra(activity4.address, joblist[position].address);
intent.PutExtra(activity4.age, joblist[position].age);
now the problem is when I do this.
string userId= Intent.GetStringExtra(id);
string userName= Intent.GetStringExtra(name);
string userAddress= Intent.GetStringExtra(address);
string userAge= Intent.GetStringExtra(age);
when I put those strings in a textview, all four textviews would show the value for "age". as if all the data that was passed is only age. can anyone answer this? the output is like this
id= 12
name= 12
address= 12
age= 12
Intent.Extras don't work like that when you use the typeOf() keyword
typeOf is a C# keyword that is used when you have the name of the class. It is calculated at compile time and thus cannot be used on an instance, which is created at runtime. GetType is a method of the object class that can be used on an instance
Since it does not initialize like that your variables that you are assigning here are currently all null so the intent carries all the data in correspondence to null, Since the first value you enter with null is id you always get id
I would suggest you save the strings in either resource strings and reuse it or do something like this :
First Activity:
Intent intent = new Intent(_context, typeOf(SecondActivity));
intent.PutExtra("Variable Name",string_to_be_sent);
startActivity(intent);
Second Activity:
//Receiving data inside onCreate() method of Second Activity
String value =Intent.GetStringExtra("Variable Name");
My SmartGWT ListGrid have some fields, wich contain long string. I set property "countryGrid.setCanResizeFields(true)".
When I change the width of the field, I want to see something like this: |A very long dat...|
Data that does not fit, will be replaced by Dots.
But instead, my string data simply cutted, like this |A very long dat|
What property is responsible?
Here is my code:
//deptartment Tab
deptGrid.setWidth100();
deptGrid.setHeight(300);
deptGrid.setTop(50);
deptGrid.setAlternateRecordStyles(true);
deptGrid.setShowAllRecords(true);
deptGrid.setCanRemoveRecords(true);
deptGrid.setCanEdit(true);
ListGridField emplIdField_DepTab = new ListGridField("id", "ID", 40);
ListGridField nameField_DepTab = new ListGridField("name", "NAM", 200);
ListGridField deptIdField_DepTab = new ListGridField("deptId", "DEPARTMENT");
ListGridField buildingIdField_DepTab = new ListGridField("buildingId", "BUILDING");
deptGrid.setFields(new ListGridField[] {
emplIdField_DepTab, nameField_DepTab, deptIdField_DepTab, buildingIdField_DepTab
});
deptGrid.setCanResizeFields(false);
deptGrid.setShowAllRecords(true);
deptGrid.setShowRecordComponentsByCell(true);
deptGrid.setFixedRecordHeights(true);
deptGrid.setAutoFetchData(true);
deptGrid.setAutoFitMaxRecords(3);
deptGrid.setAutoFitData(Autofit.VERTICAL);
deptGrid.setShowFilterEditor(true);
deptGrid.setCanEdit(true);
You don't need to write any code for this functionality. This is the by default behavior of the ListGrid.
Please have a look at Smart GWT Showcase with live sample code for more clarity.
EDIT
The issue may be caused by using older version of Smart GWT. Try it again with latest nightly build of Smart GWT.
I have a JSF application where I need to create almost all of the UIComponents dynamically based on certain parameters to the page. The components are created and added to an HtmlPanelGrid. I've been successfully creating HtmlLabel, HtmlInputText, UISelectBoolean, and HtmlCommandButton. Now I need to create an HtmlSelectOneMenu and add it, and I'm having a hard time finding examples that show how to attach the list of items to select.
The selection list is this, where I've made cfaItems a property of my backing bean:
SelectItem[] cfaItems = {
new SelectItem(1, "1"),
new SelectItem(2, "2"),
new SelectItem(3, "3"),
new SelectItem(4, "4"),
new SelectItem(5, "5")
};
The creation of the HtmlSelectOneMenu:
HtmlSelectOneMenu cfaMenu = (HtmlSelectOneMenu)
getApplication().createComponent(HtmlSelectOneMenu.COMPONENT_TYPE);
cfaMenu.setId("cfaMenu");
grid.getChildren().add(cfaMenu);
As best as I can figure it out, I need to create a ValueExpression that would bind the cfaItems list to the cfaMenu but not finding any examples is a problem. I think that I need to do something like this
String menuBinding =
"#{" + beanName + ".cfaItems}";
ValueExpression menuVE = getApplication().getExpressionFactory().
createValueExpression(FacesContext.getCurrentInstance().
getELContext(), menuBinding, String.class);
cfaMenu.setValueExpression("value", menuVE);
But I don't think that's correct. Any suggestions?
You need to create an UISelectItems instance with the given select item array as value and then add it as child of the menu, exactly as you'd do with <f:selectItems> in the view side.
UISelectItems selectItems = new UISelectItems();
selectItems.setValue(cfaItems);
cfaMenu.getChildren().add(selectItems);
Is there any way to make query in twitter4j search for more that one keyword?
Like instead of making more queries in my program I can make one which does it all, so I will have only one big stream of tweets that I can read?
I guess it would be something to replace this:
Query query1 = new Query("SOME RANDOM TEXT1" );
Query query2 = new Query("SOME RANDOM TEXT2" );
Query query3 = new Query("SOME RANDOM TEXT3" );
Query query4 = new Query("SOME RANDOM TEXT4" );
...
Create a FilterQuery object and then set the items to track
FilterQuery filterQuery = new FilterQuery();
Create an array of items to track
String[] itemsToTrack = {"python", "java", "php"};
Set the items to track using FilterQuerys' track method.
filterQuery.track(itemsToTrack);
Assuming you have already created Twitter/TwitterStream object, use the filter method to start streaming using the FilterQuery object just created.
twitterStream.filter(filterQuery);
Hope this helps.