I am trying to create FileUploadPanel that can be used in the form.
But however at runtime I facing some conversion error, I did debug the code it is going to the ConverterLocater.class in the wicket-core jar there it fails on the typecasting.
So when I debug I found filename is passed a in the below method public C convertToObject(String value, Locale locale) and in the conversion it fails because the value is string and it trying to caste to fileUpload.class.
Error:
throw (new ConversionException("Could not convert value: " + value + " to type: " + theType.getName() + ". Could not find compatible converter.")).setSourceValue(value);
Here value is passed as file name and theType is FileUpload.
I referred some examples, there setType is mandatory so I tried to set with String.class
but again next time fileUpload class was failing.
Could not convert value: test.pdf to type: org.apache.wicket.markup.html.form.upload.FileUpload. Could not find compatible converter.
I found the solution
Model name parameter was the issue, after changing this to List it got fixed.
private List<FileUpload> fileUploads = new ArrayList<FileUpload>();
new MultiFileUploadField("fileField",new PropertyModel(this,"fileUploads"),maxFiles)
I'm reading the Vue.js guide, and I've come across the statement.
Template expressions are sandboxed and only have access to a whitelist
of globals such as Math and Date. You should not attempt to access
user defined globals in template expressions.
What are all the globals available in templates?
That is, what is the content of the whitelist, exhaustively?
Vue.js defines the whitelist of globals in the core/instance/proxy.js file:
//...
const allowedGlobals = makeMap(
'Infinity,undefined,NaN,isFinite,isNaN,' +
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
'require' // for Webpack/Browserify
)
// ...
When Vue compiles the template, the string interpolations are processed, and if you reference a global that is not whitelisted, you will have a warning on Development.
If you are curious about how templates are compiled to render functions, look through the template explorer.
From what I understood from source code globals are declared in a variable and make it available via a proxy between vm instance and template :
const allowedGlobals = makeMap(
'Infinity,undefined,NaN,isFinite,isNaN,' +
'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,' +
'require' // for Webpack/Browserify
)
So gobals available in template are :
Infinity
undefined
NaN
isFinite
isNaN
parseFloat
parseInt
decodeURI
decodeURIComponent
encodeURI
encodeURIComponent
Math
Number
Date
Array
Object
Boolean
String
RegExp
Map
Set
JSON
Intl
require
If you try to put in your template a reference that is not whitelisted or not in your vm instance then you will have this warning :
Property or method "${key}" is not defined on the instance but
referenced during render. Make sure that this property is reactive
either in the data option, or for class-based components, by
initializing the property.
I am using below snippet in html
value.two-way="lstName.IsBlocked ? 'Blocked' : Value2 + ' %'"
on console it shows error as
Uncaught Error: Binding expression
"lstName.IsBlocked?'Blocked':Value2+' %'" cannot be assigned to.
at b.a.assign (aurelia.js?v=1.0009:59)
at a.updateSource (aurelia.js?v=1.0009:61)
at a.call (aurelia.js?v=1.0009:61)
at a.v [as callSubscribers] (aurelia.js?v=1.0009:58)
at a.notify (aurelia.js?v=1.0009:60) `
What can be the reason for this ?
Thanks in advance!
Since you're using a two-way binding, the binding expression needs to be assignable.
As the error says: "lstName.IsBlocked?'Blocked':Value2+' %'" cannot be assigned to.. If your bound property changes from the view, it would have to be able to write back to the expression and update the source value in your view model. You can't really write to an inline if.
Change two-way to to-view and it should work.
EDIT:
Since you need the expression to be writable, you could use a ValueConverter to solve the problem (assuming Value2 is what you want to write to):
export class BlockedValueConverter {
toView(value, isBlocked) {
return isBlocked ? 'Blocked' : value + ' %';
}
fromView(value) {
return value;
}
}
Then in your html (don't forget to require the valueConverter or use globalResources):
value.two-way="Value2 | blocked:lstName.IsBlocked"
my BuildParameter is defined in my xaml build as follows:
<Activity this:Process.AdvancedBuildSettings=
"[New Microsoft.TeamFoundation.Build.Common.BuildParameter(
" { ""Attribute1"": """",
""Attribute2"": ""Value2"",
""Attribute3"": ""Value3"" } "
)]">
Now I want to update the value of Attribute1 of my BuildParameter but I can't figure out how to do it.
It doesn't look like I can use an Assign block because these attributes names are not known by the compiler, so I want to use BuildParameter's SetValue method but I'm not sure how to call this VB code in my xaml.
<Assign DisplayName="Update That Attribute">
<Assign.To>
<OutArgument x:TypeArguments="x:String">[AdvancedBuildSettings.Attribute1]</OutArgument><!-- this throws a compiler error because it doesn't know what Attribute1 is -->
</Assign.To>
<Assign.Value>
<InArgument x:TypeArguments="x:String">""NewValue""</InArgument>
</Assign.Value>
</Assign>
Not familiar with XAML, but here is a code snippet that using TFS API in C# to update the parameter name. You can use WorkflowHelpers.DeserializeProcessParameters Method and WorkflowHelpers.SerializeProcessParameters Method to get parameter name, remove it, and add the new parameter name, maybe it can help you something:
string argumentName = "Attribute1";
var process = Microsoft.TeamFoundation.Build.Workflow.WorkflowHelpers.DeserializeProcessParameters(BuildDefinition.ProcessParameters);
if (process.ContainsKey(argumentName))
{
process.Remove(argumentName);
process.Add(argumentName, attributeValue);
BuildDefinition.ProcessParameters = WorkflowHelpers.SerializeProcessParameters(process);
BuildDefinition.Save();
}
I was right, the "Assign" workflow tool was not the tool I wanted. I needed to use the "InvokeMethod" workflow tool in order to invoke the SetValue() method of my BuildParameter object in my XAML build.
MSDN InvokeMethod documentation
More details about the properties of InvokeMethod
So my solution looks like this:
<InvokeMethod DisplayName="Invoke That Method" MethodName="SetValue">
<InvokeMethod.GenericTypeArguments>
<x:Type Type="x:String" />
</InvokeMethod.GenericTypeArguments>
<InvokeMethod.TargetObject>
<InArgument x:TypeArguments="mtbc:BuildParameter">[AdvancedBuildSettings]</InArgument>
</InvokeMethod.TargetObject>
<InArgument x:TypeArguments="x:String">Attribute1</InArgument>
<InArgument x:TypeArguments="x:String">[NewValue]</InArgument>
</InvokeMethod>
I have a bean property in my form as follows (rates is a HashMap from FleetRateTypeCO to FleetRate[]):
public FleetRate[] getRatesByType(int typeID) {
return this.rates.get(FleetRateTypeCO.getByID(typeID));
}
Then in my jsp I want to do the following:
<c:when test="${not empty DedicatedFleetContractAdminForm.ratesByType[1]}">
...
</c:when>
But I get a null pointer exception:
java.lang.NullPointerException
at javax.el.BeanELResolver$BeanProperty.read(BeanELResolver.java:259)
at javax.el.BeanELResolver$BeanProperty.access$000(BeanELResolver.java:209)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
at org.apache.el.parser.AstValue.getValue(AstValue.java:97)
at org.apache.el.parser.AstEmpty.getValue(AstEmpty.java:29)
But what really confuses me is that if I try the following, it works fine:
<logic:iterate property="ratesByType[1]" name="DedicatedFleetContractAdminForm" id="overheadRates">
...
</logic:iterate>
Why would they work differently? Any help is appreciated - thank you in advance.
In one you are using the struts tags, and in the other EL.
Try using the struts tag