Optional param in VXML subdialog - vxml

For our product we have to use a VXML subdialog to another external file, but this given subdialog have less var elements than the param elements we are sending.
Here is an example
<subdialog ...>
<param name="Param1" expr="'1'"/>
<param name="Param2" expr="'2'"/>
...
</subdialog>
In the caller, and
<form ...>
<var name="Param1"/>
...
</form>
Is there a way to declare a param as optional in a subdialog ?
Many thanks,

The W3C recommendation doesn't say anything about an optional param. What it says is:
name: The name to be associated with this parameter when the object or subdialog is invoked.
expr: An expression that computes the value associated with name.
value: Associates a literal string value with name.
valuetype: One of data or ref, by default data; used to indicate to an object if the value associated with name is data or a URI (ref). This is not used for since values are always data.
type: The media type of the result provided by a URI if the valuetype is ref; only relevant for uses of in .
However, if you're sending more parameters than what you're going to use in your subdialog, you won't have any problems. Those params which aren't used would just get lost in the subdialog context.

As an answer to myself, sadly there is no possibility you can pass more parameters to a subdialog than it expects.
Thus, we have to pass the exact same amount of parameters as the numbers of variables that are declared in the form.

Related

Camel bean binding: set parameter from variable

Given a bean method that takes a String parameter:
public void emptyDirectory(String directory) {
// code to empty give directory if it exists
}
how do i pass this parameter? The method is called here:
String to = configuration.getTo();
from(configuration.getFrom())
.to("bean:splitFileByProductType?method=emptyDirectory(to)")
....
This doesn't work as 'to' evaluates to "to", and not the value of configuration.getTo().
The documentation does not mention a case like this, so i don't know if what i'm trying to do is even possible, for example in the Simple language.
I know the value becomes accessible if i add it to the exchange header or if i hardcode it.
You can pass a value as method argument with ${body}, ${body.NAME}, ${property.NAME} and ${header.NAME}.
Examples http://camel.apache.org/bean-binding.html
So first of all you have to put your variable in Camel exchange.
To pass information from the Camel Exchange to a bean method you must not add or change anything in the route.
If you have this route (from your question). Notice that if the bean has only one method you can omit the method name.
from(whatever)
.to("bean:splitFileByProductType?methodName=emptyDirectory")
Or alternative
from(whatever)
.bean(splitFileByProductType, "emptyDirectory")
You can annotate your bean method to get the needed Exchange information automagically:
public void emptyDirectory(
#Header("directory") String directory,
#Body String body
... [other stuff to be injected] ) {
// your method impl
}
See the Camel docs for more information about this feature.
You could assign the parameter to an exchange header or property and then use simple language to pass it the bean method
String to = configuration.getTo();
from(configuration.getFrom())
.setHeader("foo", constant(to))
.to("bean:splitFileByProductType?method=emptyDirectory(${header.foo})")
...
From documentation:
The only things that can be passed to a bean are Simple tokens, a String value, a numeric value, a boolean or null.
The variable from the example cannot be expressed using Simple. What can be expressed are various properties of the exchange, most notably the exchange headers, and also some random things like literally random numbers, the current date and so on. Check the documentation for more info.
I decided to treat the whole thing as a code smell, and moved the method to a utility class which i call prior to initializing the route.

What is the keyword for local currency in chained angular currency filter? (without custom directive)

I have looked in documentation, but I can't find the answer I'm looking for.
I also know I can make a custom filter to handle this use case, but I wanted to avoid doing that.
My goal is to show a currency result that has no decimal places, but also uses the default / local currency type.
That is to say, I don't want to specify a particular type of currency, I'd just like the default type.
I know that I can chain together number filters and currency filters if I provide an explicit type of currency (eg | currency: "$" : 0 ), however, I can't assume which country
(I've noticed that if I put in any nonsense word without quotes as a parameter, it'll work. i.e.- where 'foobar' is below. I don't want to use a nonsense word, though, I'd like to do it the right way.)
<span>
{{ctrl.totalSum | currency: foobar : 0}}
</span>
So far, I have tried: null, "null", local, "local", "", "undefined", and empty content. I can't seem to determine what the proper keyword is to indicate I want the default value.
After further research, it appears that I can use undefined as a parameter, as described on MDN:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined
It appears to be a primitive type that can be passed in.
The following syntax worked for me:
<span>
{{ctrl.totalSum | currency: undefined : 0}}
</span>
After looking through the base angular library, I see that there is a check for whether this parameter is undefined. By passing in a primitive undefined type, it prompts the local symbol logic:
return function(amount, currencySymbol){
if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM;
return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2).
replace(/\u00A4/g, currencySymbol);
};
}

DirectCast (or alternative) with a value from Array Of Type as second argument?

I am writing a Class to error report explicitly to users who sent copied & pasted data via ajax.
I am trying to properly cast Types for INSERTion into sql server.
The user's data is stored in an Object(,). The Types are passed via ByVal ColumnTypes() As Type and stored inline:
{
GetType(Integer), GetType(String), GetType(Integer)
}
for example.
How can a value from the Array Of Type be used as the second argument of DirectCast (or an alternative to DirectCast)?
psuedo
DirectCast(thisVariable, ColumnTypes(0))
for an Integer
Unfortunately there is no way to achieve this. The DirectCast expression can only work with named types. Essentially values that are resolvable at compile time. The expression ColumnTypes(0) is only resolvable at runtime and hence can't be used with DirectCast in this manner.
Instead of DirectCast try using TypeConverter
TypeConverter.ConvertTo(thisVariable, ColumnTypes(0))

FrameworkElement.Name problem

I am attempting to set the Name property of a Page in the constructor:
public partial class PageListView : Page
{
public PageListView(string title)
{
InitializeComponent();
Name = title;
}
}
However, I often get the following error message.
'x' is not a valid value for property 'Name'.
Where x seems to be almost anything, drilling down into the exception details doesn't seem to provide any useful information (e.g. the InnerException is null.)
Does anyone know what is happening here?
The Name property generally follows the rules of C#/VB.NET identifiers (i.e. fields). Based on the documentation:
The string values used for Name have some restrictions, as imposed by
the underlying x:Name Directive defined by the XAML specification.
Most notably, a Name must start with a letter or the underscore character
(_), and must contain only letters, digits, or underscores.
Based on the parameter you are passing (i.e. title), it seems like you may violate that. But you'd have to give some specific examples to be sure.
Of course, moments after posting this I realised what's going on.
Because FrameworkElement.Name is used for creating object references, you have to ensure that the string contains only valid chars for an object instance variable name.
Use Title or another plain text property instead, unless you really want to set the x:Name property for referencing.

Pass array as parameter to JAX-RS resource

I have many parameters to pass to the server using JAX-RS.
Is there a way to pass or AarryList with the URL?
You have a few options here.
Option 1: A query parameter with multiple values
You can supply multiple simple values for a single query parameter. For example, your query string might look like:
PUT /path/to/my/resource?param1=value1&param1=value2&param1=value3
Here the request parameter param1 has three values, and the container will give you access to all three values as an array (See Query string structure).
Option 2: Supply complex data in the PUT body
If you need to submit complex data in a PUT request, this is typically done by supplying that content in the request body. Of course, this payload can be xml (and bound via JAXB).
Remember the point of the URI is to identify a resource (RFC 3986, 3.4), and if this array of values is data that is needed to identify a resource then the URI is a good place for this. If on the other hand this array of data forms part of the new representation that is being submitted in this PUT request, then it belongs in the request body.
Having said that, unless you really do just need an array of simple values, I'd recommend choosing the Option 2. I can't think of a good reason to use URL-encoded XML in the URL, but I'd be interested to hear more about exactly what this data is.
We can get the Query parameters and corresponding values as a Map,
#GET
#Produces(MediaType.APPLICATION_JSON)
public void test(#Context UriInfo ui) {
MultivaluedMap<String, String> map = ui.getQueryParameters();
String name = map.getFirst("name");
String age = map.getFirst("age");
System.out.println(name);
System.out.println(age);
}

Resources