Multiple button form cause invalid arguments error - haskell

I want to add another button to a working monadic get form, which triggers a different processing of the entire form (like preview and submit buttons commonly found in forum post forms).
So I tried to follow the advice from this answer to this older question:
First, adding another named input button:
<input type="submit" name="preview" value="Preview">
Second, adding a call to runInputGet:
((res,widget),enc) <- runFormGet myform
isPreview <- runInputGet $ iopt boolField "preview"
... -- pre-processing the form input, i.e. basic error checks
case (isPreview,res') of
(Just True, Just checkedRes) -> ... -- preview processing
( _ , Just checkedRes) -> ... -- proper processing
Unfortunately, it does not work: whenever I press my new button, I get an invalid arguments page, saying that there is an invalid boolean with the name attached to the second submit button.
A difference to the earlier question is, that I am using a GET form instead of a POST from. However, it appears to me that I need to include the boolean field in the original form, but adding an optional boolean field with the same name in the original monadic form does not change anything at all:
_ <- mopt boolField ((String.fromString "preview") { fsName = "preview" }) Nothing
(I do not know what to do with the result from this mopt, as I neither need the view (no additional form field should be shown to the user) nor the result (since this is what the additional runInputGet already provides for))

If you look at the code for boolField, you'll see that it has a strict requirement for the format that the value is supposed to be in. Instead, you probably want to use textField- which accepts anything- and then simply test if the value was present.

Related

Ensure one thing, and then another one if first is false

I have an interface with a list of users and a possibility to add a new one. I want to assert that this user is new (i.e. its email is not already used). So I should check that we have no message pop-up.
checkMailIsNotUsed: () =>
Task.where('#actor checks mail present message is absent',
Ensure.that(UsersList.messageArea, not(isVisible()))),
However this message area could be visible but not with the error messsage I don't expect. So I am looking for, in case above ensure fails, a way to ensure that the text does not include 'already exists'.
Ensure.that(Text.of(UsersList.messageArea), includes('already exists'))),
However if the first 'ensure' is false, everything stops. There is no 'or' or equivalent at the Ensure level. I need to do the second Ensure if first one fails.
How could I do that ?
Thanks in advance.

How to make TAG_ALPHA_IDENTIFIER empty not to ask user for a confirmation

My wallet applet requires to perform actions like PLAY TONE etc. But it requires a prompt "Yes or No?" from user. AFAIK, it is TAG_ALPHA_IDENTIFIER which is responsible for that. However, if I try this code below, it still asks user confirmation but now with "#" text. How to get rid of user confirmation at all?
Attempt 1. Failed with NullPtrException
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, null, (short)0, (short)0);
proHdlr.send();
Attempt 2. Prompts '##'
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, (byte)0, (byte)0);
proHdlr.send();
Attempt 3. Prompts '#'
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, (byte)0);
proHdlr.send();
Attempt 4. Prompts Default Text
byte[] ALPHA_MSG = {};
proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER, ALPHA_MSG, (short)0, (short)ALPHA_MSG.length);
proHdlr.send();
According to ETSI 102.223, "8.2 Alpha identifier" section, it should be:
Description
Length
Alpha identifier tag
1
Length(X)
Y
Alpha identifier
X
And there is also "Default text" in documentation, however since "5.3.7 Text attributes" requires Alpha Identifier to be present, Default text should not bother, right?
In this document "6.4.5 PLAY TONE" section, page 45 it says:
if the alpha identifier is provided by the UICC and is a null data object (i.e. length = '00' and no value part), the terminal should not give any information to the user;
That's what I need. How should I do it Java with ProactiveHandler? All my Google searches end up with some text/menu title for Alpha Identifier.
How to get rid of user confirmation and perform the proactive action without it?
a) Try to pass no data at all, i.e. leave out the proHdlr.appendTLV(ToolkitConstants.TAG_ALPHA_IDENTIFIER line.
b) The behavior might be phone-related or more specific modem-related. Check out a MediaTek based one, a Qualcomm based one and an iPhone and compare the results.

FIXED -- Voice prompt for Measurement concept from Library capsule does not work for Bixby runtime version 6

I have a very simple action where it takes a single parameter of type measurement.Length. if user does not provide the value for this parameter i want to prompt user for missing value.
To do this i designed my action like below
action (AddDistance) {
description (adding exercise)
type(Search)
collect {
input (distance){
type (measurement.Length)
min (Required) max (One)
}
}
output (Result)
}
I have added a NL training [g:Result] add distance of (2 km)[v:measurement.Length] which learned perfectly and giving this utterance works fine.
Now if i give the utterance like "add distance" the Bixby does not prompt for the missing input value instead give error with description
TypeError: Cannot read property 'display' of undefined1000Cannot read property 'display' of undefinedTypeError: Cannot read property 'display' of undefined at
What should i do show prompt for this concept measurement.Lenght from Library capsule.
N.b. voice prompt works on runtime version 5 with no issue.
This is an important change, for runtime-version above 5, in order to use default dialog (which is true in many library capsules), developer needs to include the following override in capsule.bxb.
runtime-version (6) {
overrides {
no-fallback-dialog-in-views (false)
}
}
The original bug cause the JS error has been fixed, but override is required to render library dialog.
Library capsules already got input-view and voice training handled. From your last capsule, change distance to Required in action model, and add following training missing distance.
The input-view would be triggered, and let's use voice-input
It runs fine to result-view, and confirmed on debugger
BTW, to replace the default "I need ..." message, add a dialog model as this
dialog (Elicitation) {
match: measurement.Length
template("How far would you like to run")
}

Cucumber "OR" clause?

Is it possible to specify some kind of "OR" (alternative) clause in Cucumber?
I.e. if I have two valid responses to some event I would like my test to pass if either of them happens.
Something like that:
"When I press a button"
"Then I should see the text 'Boo'"
"Or I should see the text 'Foo'"
My particular scenario is a login screen. When I try to log in with some random password, I should see an error message "invalid password" if the server is working or a message "network error" if it is not.
You can't really define OR functionality using the Gherkin but you can pass in a list and check that one of the values in the list matches what was returned.
Define list:
Then the greeting service response will contain one of the following messages
|Hello how are you doing?|
|Welcome to the front door!|
|How has your day been?|
|Come right on in!|
Check list:
#Then("the get messages service response will contain one of the following messages")
public void text_matching_one_of_the_following(List<String> greetingMessages){
boolean success = false;
for(String message : greetingMessages){
assertTrue(textMatchesResponse(message));
}
}
OR is not supported. You can use Given, When, Then, And and But. Please refer to http://docs.behat.org/en/v2.5/guides/1.gherkin.html
But perhaps you could make use of the But keyword to achieve what you are looking for.

Validate value in field

Is there anyway to check when you type in to a field if there already are any document saved with that value in that field. Ex, if you type projectno i want to check if any other document already have that projectno. Any suggestion how i will validate that
Regards
You need a view in the database that is sorted in the first column by the field that you are using. I will assume it is a hidden view, called "(lookupUnique)". Build it and test it to make sure it is showing the field that you want in the first column, and that the values are sorted.
Now you need a way to do a lookup into this view. Ideally, you're wanting the lookup to fail -- because there is no document with the same value, in which case you allow the save to continue. But there's one other case where you might want to allow the save to continue. That's the case where the lookup succeeds because the lookup found the document that you are working on right now, which was previously saved and therefore is found in the view, and a user is now editing it again.
The #DbLookup function with the [RETURNDOCUMENTUNIQUEID] and [FAILSILENT] arguments is the IBM-recommended solution for this. I.e.,
foundId := #DbLookup("Notes":"NoCache";"":"";"(lookupUniqe)";theUniqueFieldNameGoesHereWithoutQuotes;1;[RETURNDOCUMENTUNIQUEID]);
If this formula returns "", then no match was found, therefore your code should return #Success to let the save continue. If it returns anything else, then compare the result with #DocumentUniqueId. If they match, then your code should return #Success to let the save continue. If they do not match, then you have found another document with the same value in the field, so your code should return #Failure with an appropriate error message.
Now here's the caveat: there have been known problems with [RETURNDOCUMENTUNIQUEID] in some versions of Domino, including a bug that caused Domino 6 servers to crash if an agent called ComputeWithForm on a document based on a form that used this feature. There's also a bug that causes it to return only the unid of the first match out of many matches, and so if you have duplicates this strategy in your code will allow users to re-save old documents that are already non-unique instead of forcing them to change them to make them unique, and that may or may not be what you want.
If either of those known issues might create a problem for you, then you would be better off not using [RETURNDOCUMENTUNIQUEID], and instead just do what Notes and Domino programmers did before IBM added the [RETURNDOCUMENTUNIQUEID] option in the first place: add another column to your (lookupUnique) view, and set the column value to #Text(#DocumentUniqueId). Change the 1 in the above #DbLookup formula to the number of the column that you added, and write your validation code to anticipate the possibility that you might get back an empty string, a single value, or a list of values.
If a type 45678 i return a value because there already are a document with that value. I don’t understan how i will validate it.
var dbname = session.getServerName() + "!!" + "proj\\webno.nsf";
getFieldValue = getComponent("oNo").getValue();
tmp = #DbLookup(dbname, "(webNo)", getFieldValue, ”obNo”);
if (tmp == getFieldValue)
{
Here i will do a validate. If value i return are the same as in the getFieldValue
and tmp or just getFieldValue is empty.
}
else
{
Here is it OK
}
Taking your code and modifying it. Assuming we're in the database we're creating the document in, just use #DbName() instead of trying to build the name from the session and some hard-coding. When using validation, the value of the control should be accessible simply with value. Then, just get all the values in the column and see if your value is in there.
I think the following should work.
<xp:inputText id="projectNumber" value="#{doc.ProjectNumber}">
<xp:this.validators>
<xp:validateExpression message="Value already in use">
<xp:this.expression><!CDATA[#{javascript:var usedValues = #DbColumn(#DbName(), "(webNo)", 1);
if ( #IsMember ( value, usedValues ) ) { return false };
return true;
</xp:this.expression>
</xp:validateExpression>
</xp:this.validators>
</xp:inputText>
Why don't you just generate a value for them? The simplest would be to use #Unique, but there are plenty of other ways besides having them have to create one.....

Resources