Here's the Flutter code:
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding:
const EdgeInsets.only(bottom: LuminaSpacing.extraTiny),
child: RichText(
key: Key('last_updated'),
textAlign: TextAlign.end,
text: TextSpan(
text: '${_localize.last_updated}: ',
style: wldTheme.textTheme.display1,
children: <TextSpan>[
TextSpan(
text: '${settingStore.lastCheckinTime}',
style: wldTheme.textTheme.body1),
],
),
),
),
I'm using appium with java to automate my test cases
Here's my code:
FlutterFinder ele = new FlutterFinder(driver);
System.out.println("Last update: "+ele.byValueKey("last_update"));
// System.out.println("Last update: "+ele.byValueKey("last_update").getText()); // It waits for long duration
The output I get is
Last update: [pro.truongsinh.appium_flutter.finder.FlutterElement#870fb657 -> unknown locator]
you need to create a controller like this: var textController = TextEditingController(); and aggregate the controller to your RichText widget, with this controller you can get the value of the text like this: textController.text
Related
I was making a BottonNavigation bar in flutter dart and i am getting an error
the code is
This the code
the error is
And this the error pls help
I want a solution for this error if someone can help me i will thank them a lot
The console version is this
you need to pass NavigationDestination instead of NavigationDrawerDestination in the destinations params
** sample code snippet **
bottomNavigationBar: NavigationBar(
onDestinationSelected: (int index) {
setState(() {
currentPageIndex = index;
});
},
selectedIndex: currentPageIndex,
destinations: const <Widget>[
NavigationDestination(
icon: Icon(Icons.explore),
label: 'Explore',
),
NavigationDestination(
icon: Icon(Icons.commute),
label: 'Commute',
),
NavigationDestination(
selectedIcon: Icon(Icons.bookmark),
icon: Icon(Icons.bookmark_border),
label: 'Saved',
),
],
),
follow official documentation https://api.flutter.dev/flutter/material/NavigationBar-class.html (material you/3)
or If you are using other package for it check its documentation
or you can also use
https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html (material 2)
If you can help me, I have an update in mongo with $cond , this update is only done if the field is empty, otherwise it updates the field with another value. Example in mongo db
I want to update the field camp1
if camp1 no exits = values
if camp1 exits = value2
db.getCollection('prueba').update(
{"cdAccount": "ES3100810348150001326934"},
[{$set:{camp1 :{"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}}}]);
Result:
{
"_id" : ObjectId("62dd08c3f9869303b79b323b"),
"cdAccount" : "ES3100810348150001326934",
"camp1" : "value2"
}
Now I do the same in scala with this code
def appendIfNotNull(key: String,value :Object) = {
var eq2Array = new util.ArrayList[Object]()
eq2Array.add("$"+key)
val eq2Op = new Document("$not", eq2Array)
var condList = new util.ArrayList[Object]()
condList.add(eq2Op)
condList.add(value.asInstanceOf[AnyRef])
//condList.add("$"+key)
condList.add("value2")
val availDoc =
new Document("$cond",
new Document("$cond", condList)).toBsonDocument(classOf[BsonDocument],getCodecRegistry).get("$cond")
println("availDoc : " + availDoc)
documentGrab.append(key,availDoc)
}
val finalVar = appendIfNotNull("camp1","values")
println("finalVar : " + finalVar)
availDoc : {"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}
finalVar : Document{{camp1={"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}}}
val updateDocument = new Document("$set" , finalVar )
println("updateDocument : " + updateDocument)
collectionA.updateMany(Filters.eq("cdAccount", "ES3100810348150001326934"),updateDocument)
The only difference I see is that in mongodb the "[" is added at the beginning of the $set and it does it well
MongoDB
[ {$set:{camp1 :{"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}}} ] --> Ok Update
Scale
{$set:{camp1 :{"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}}} --> Ok in scala , but I get the result II
I am using mongodb 5.0.9
Now in mongodb I execute the statement made in scala
db.getCollection('prueba').update(
{"cdAccount": "ES3100810348150001326934"},
{$set :{camp1 :{"$cond": [{"$not": ["$camp1"]}, "values", "value2"]}}});
When I run it in scala the same thing happens
Result II :
{
"cdAccount" : "ES3100810348150001326934",
"camp1" : {
"$cond" : [
{
"$not" : [
"$camp1"
]
},
"values",
"value2"
]
}
}
Can someone tell me how to fix it?
Thank you so much
You see the very important difference when priting the queries.
$cond is an aggregation pipeline operator. It is processed only when aggregation pipeline is used to update the data. When a simple (non-pipelined) update is used, the operator has no special meaning and this is exactly what you see in the output.
You indicate "pipeline update" by passing an array instead of simple object as update description in javascript API (and mongo console). In Scala/Java you have to use one of the updateMany overloads that takes update description as List, not Bson. I.e. you need something like
collectionA.updateMany(
Filters.eq("cdAccount", "ES3100810348150001326934"),
Collections.singletonList(updateDocument)
)
i'm new in ExtJS and Servlet.
I created a form with 2 fields usinf ExtJS :
var panel = Ext.create('Ext.form.Panel',
{
title: 'Personnal Data',
bodyPainting: 5,
width: 350,
region:'center',
url: 'save_form.php',
items:
[{
xtype: 'textfield',
fieldLabel: 'First Name ',
name: 'firstName'
},
{
xtype: 'textfield',
fieldLabel: 'Last Name ',
name: 'lastName'
}],
buttons:
[{
text: 'Submit',
handler: function()
{
var formData = this.up('form').getForm();
}
}]
});
But i don't know how to pass the value of the two fields to a servlet, by clicking on the button.
And how can i retrieve the data entered in the form, in the servlet ?
Thank you !
By default ExtJS Forms will send over the values in an "ajax" fashion and I believe it will be a "post". In your servlet (assuming you are posting to a servlet defined in your web.xml file) in your doPost (or doGet) methods, use the "request" variable in the method and do
request.getParameter("firstName")
and
request.getParameter("lastName")
.
Link to HttpServlet Definition (is the same for just about every java container).
Edit:
In your handler you need to add:
formData.submit();
So I am trying to add a combobox that has 2 values on the same line as my text field, but am having trouble doing so.
This is what it looks like right now:
I want to be able to move the combobox to the left of the 2 textfields that I have.
This is the code that I have for my combobox which I have placed outside of my Formpanel:
var cbTemplate = new Ext.form.ComboBox({
typeAhead: false,
width: 125,
hideTrigger:true,
allowBlank: true,
displayField: 'val',
});
// ComboBox for switching status
var carWeightData={lstValueRecords: [{val: 'Item 1'},{val: 'Item 2'}]};
var cbCombo = jQuery.extend(true, {}, cbTemplate);
cbCombo.id = 'cbCarWeight';
cbCombo.name = 'cbCarWeight';
cbCombo.emptyText = 'Please Select';
cbCombo.hideTrigger = false;
cbCombo.mode = 'local';
cbCombo.triggerAction = 'all';
cbCombo.store = new Ext.data.Store({
data: comboData,
reader: new Ext.data.JsonReader({
root: 'lstValueRecords',
fields: [
{name: 'val', mapping: 'val'}
]
})
});
So I am trying to add a combobox that has 2 values on the same line as my text field, but am having trouble doing so.
This is what it looks like right now: combobox
I want to be able to move the combobox to the left of the 2 textfields that I have.
This is the code that I have for my combobox which I have placed outside of my Formpanel:
var cbTemplate = new Ext.form.ComboBox({
typeAhead: false,
width: 125,
hideTrigger:true,
allowBlank: true,
displayField: 'val',
});
// ComboBox for switching status
var carWeightData={lstValueRecords: [{val: 'Item 1'},{val: 'Item 2'}]};
var cbCombo = jQuery.extend(true, {}, cbTemplate);
cbCombo.id = 'cbCarWeight';
cbCombo.name = 'cbCarWeight';
cbCombo.emptyText = 'Please Select';
cbCombo.hideTrigger = false;
cbCombo.mode = 'local';
cbCombo.triggerAction = 'all';
cbCombo.store = new Ext.data.Store({
data: comboData,
reader: new Ext.data.JsonReader({
root: 'lstValueRecords',
fields: [
{name: 'val', mapping: 'val'}
]
})
});
This is my textfield portion which is inside the FormPanel and inside a column:
columnWidth:.6,
layout: 'form',
items: [
cbCombo,{
xtype: 'container',
layout: 'hbox',
hideLabel: true,
labelStyle: 'width: 105px',
fieldLabel: 'Combo Data',
anchor: '90%',
items:[{
xtype:'textfield',
name: 'locationId1',
flex: 12
},{
xtype: 'label',
margins: '0 0 0 5',
text:'-',
flex: 1
},{
xtype:'textfield',
name: 'locationId2',
flex: 12
}]
}]
Is there anyway that I could move the combobox down to be next to the texfield?
Please help!
Why don't you just do the same as your text fields?
items: [
{
xtype: 'combo',
// combobox configuration
},{
xtype:'textfield',
name: 'locationId1',
flex: 12
},
...
]
Nothing prevents you from putting an instantiated component in there, either:
items: [
new Ext.form.ComboBox({
// combobox configuration
}),
{
xtype:'textfield',
name: 'locationId1',
flex: 12
},
...
]
Extending an Ext component with jQuery is something I would refrain myself from doing, however o_O
I am trying to return two json sets from java which each contain key/value pairs. I can get the data to return as expected but once I have the data I can not access it properly. Here is what my data coming from the java looks like
{"RESULTS":
{"MAP_1":
[
{"value":"1","display":"output text","type":"type a"},
{"value":"2","display":"more output text","type":"type a"}
],
"MAP_2":
[
{"value":"1","display":"output text","type":"type b"},
{"value":"2","display":"more output text","type":"type b"}
]
}
}
I have tried using $.map and $.each but I can not seem to drill into the data any help would be greatly appeciated.
Here is my latest attempt:
$.ajax({
url: url,
dataType: "text",
data: {
searchString: request.term
},
success: function( data ) {
response( $.map( data.MAP_1, function( item ) {
label: item.value + ", " + item.type
value: item.display
}));
}
});
Thanks in advance!
The format of the data returned by java is text, not json. So you should specify the dataType as json. In addition the following code are not right, I think.
data.MAP_1
should be
data.RESULTS.MAP_1