In my project, I have this config in struts.xml
<action name="searchTracker" class="searchAction" method="searchTracker">
<result name="success">/jsp/searchTracker.jsp</result>
<result name="error">/jsp/searchTracker.jsp</result>
</action>
And here is my action method in searchAction Action
public String searchTracker(){
this.clearErrorsAndMessages();
List<File> queryResults = fileManager.retrievequeryResults(patchNumBySearch); // patchNumBySearchis input from the page
if(queryResults == null){
this.setTrackers(null);
addActionError("This patch number doesn't exist. Please choose another one !");
return ERROR;
}
List<Tracker> trackers = commonUtils.convertToTrackers(queryResults);
this.setTrackers(trackers);
}
return SUCCESS;
}
if I input wrong param and the queryResult is returned as NULL, the page searchTracker.jsp can correctly show error message in itself as I wish, but after this, I enter correct param, it show error directly below
"Errors on action com.harris.northstar.dbadesk.action.SearchTrackerAction#9bee3a, returning result name 'input'"
I just compared debug log in two different case, and found that only one line difference
"converter is null for property patchNumBySearch. Mapping size: 0"
if this line exists, it will go into my action, if not, it will go to the error asking for input result. What is the line meaning?
and didn't get into the action class yet. I know the reason is that it violate some default validation interceptor and throw this exception, but I can't find anything wrong with this request with correct param. If I enter correct param firstly, it can get queryResult and goes to Success result without problem. The only different is timing.
Do I have to add input result in the configuration xml? I met some project before, and they only has success and error result, no input result at all, why it doesn't works? Something is wrong with my struts.xml?
And I don't want to create my own interceptor by disabling struts default validation interceptor
I just found a way to walk around it. just delete error result in configuration file, only keep success result, and remove AccionErrors in method searchAction, so user wont' get any warning message for their query request, just show nothing on the page, but this way is secondary option. I still want to show up the error message by solving this problem.
The input result would be called when a validation error occurs before transferring the control to the action method. In this case, I suggest that, you define a result type input to the initial jsp and try printing the fielderrors and actionerros using <s:fielderror /> and <s:actionerror /> respectively. This will give you a better outlook and you will come to know how to handle this in the next step depending on the error type.
Related
For example if user dont fill this field and press "continue" button, this error message will pop up.
I wonder is there a way with Cypress that I check that error message was displayed?
Kind regards
You can make this assert : cy.get('input:invalid').should('have.length', 1)
See https://github.com/cypress-io/cypress-documentation/pull/1919/files how to assert the validation message
I know this is an older question but here is another solution.
cy.get(`[data-testid="XXXX"]`)
.invoke('prop', 'validationMessage')
.should((text: string) => {
expect(text).to.contain(YYYY);
});
Using the above code here is what happens:
You grab the input / textarea element using cy.get Note: it is recommended to use a data-testid or obtain the element by something less brittle so the test doesn't fail if the text changes etc.
Using the invoke method, you can check validationMessage against prop then then, obtain the inner text and use expect to check if it's valid. This is very handy if you use custom validation messages.
I have a form page and all field is required when press save the below message appear
How i can change this message to custom message "please fill all required fields " , and how i can clear error when enter value (when value change to not null).
I can't see images at the moment.
However, one option might be to create your own validation which returns error text. Something like
if :P1_NAME is null then
return ('Name must be entered');
end if;
Messages are automatically cleared once you submit the page and there are no errors left.
I am not sure if you can change system messages but you can add custom error messages with javascript if a change happens in any item.
Add a change event to the item that runs javascript and use the following code:
var item = apex.item('P1_ITEM').getValue();
if(item == null) {
//First clear the errors
apex.message.clearErrors();
// Now show new errors
apex.message.showErrors([
{
type: "error",
location: [ "page", "inline" ],
pageItem: "P1_ITEM",
message: "Name is required!",
unsafe: false
},
{
type: "error",
location: "page",
message: "Page error has occurred!",
unsafe: false
}
]);
}
However, this will not stop the user from submitting, it only allows you to better display the messages, so you must add the corresponding validations after submit.
If you want to remove the system error message from the required items, you can disable the option of Value Required on item and add a custom validation as they told you in the other response.
If you want to explore all the apex.message options better, I recommend this documentation:
https://docs.oracle.com/database/apex-5.1/AEAPI/apex-message-namespace.htm#AEAPI-GUID-D15040D1-6B1A-4267-8DF7-B645ED1FDA46
More documentation for apex.item:
https://docs.oracle.com/cd/E71588_01/AEAPI/apex-item.htm#AEAPI29448
There are some ways for how to do such things.
Firstly you have the custom Validations you can make, these are awesome and you should really try to use them if possible.
Then there is also the Error message on the saving procedure, but this just throws a custom message on procedure fail so I never use it.
What you appear to be seeing there is that you got an error message and didnt change the fields associated with the error.
If the save procedure is custom, you can also put in an EXCEPTION block before the END, and catch errors there and throw out a custom error with a custom error message.
Another thing I really like is to actually rename some common errors so I dont have to catch them all individually. Say clients may often times try to save identical data, thus breaking the PK. Oracle will throw an error, but the message is good for the developer, but less understandable for the client whom I always assume is a 3 year old kid who can barely read and will cry over everything. So I make an error handling function, add it to apex, and so when the error occurs, it throws a nice message informing the client that they have tried to add some data that already exists.
So, an error handling function associated with APEX, to rename some normal errors.
Good luck
Using requery version 1.5.0 ReactiveEntityStore for select calls.
But the compiler giving error for below call -
Observable<Result<Person>> result = mDataStore
.select(Person.class)
.where(Person.CATEGORY.eq(category))
.orderBy(Person.SEQUENCE.asc())
.get()
.observableResult();
Error details:
https://i.stack.imgur.com/bdPlY.png
I'm not sure about how you got that particular error message (maybe I can edit if you add more information about the actual classes involved).
However, it seems like you are mixing Result with ReactiveResult, what you want is probably:
// Supposing this is your definition of the data store:
ReactiveEntityStore<Person> mDataStore;
// Your result is going to be Reactive, next line is the one changed!
Observable<ReactiveResult<Person>> result = mDataStore
.select(Person.class)
.where(Person.CATEGORY.eq(category))
.orderBy(Person.SEQUENCE.asc())
.get()
.observableResult();
I'm trying to get some data from Application.Current.Properties storage. Unfortunately, any time I want to use this Dictionary, I see this error:
An exception of type 'System.AggregateException' occurred in mscorlib.ni.dll but was not handled in user code
Additional information: One or more errors occurred.
And in details I found this:
{"Error in line 1 position 206. Element 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:Value' contains data of the 'http://schemas.microsoft.com/2003/10/Serialization/Arrays:ArrayOfstring' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'ArrayOfstring' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer."}
It seems like I tried to save some non-string data to Application.Current.Properties. Unfortunately I can't run .Clear() method to erease all data, bacause I receive this error any time I'm trying to access this property.
What should I do to make it work?
Well, as its name suggests AggregateException, is just a container for one or more exceptions which may be thrown when using PLINQ or TPL.
As such exceptions may be thrown on different threads and may also occur concurrently, the system automatically catches and rethrows them within an AggregateException wrapper to ensure that they all get reported in one place. The exceptions themselves are exposed via the InnerExceptions property.
You can catch an AggregateException and check which exceptions it actually contains with code such as the following:
try
{
// perform some parallel operation
}
catch (AggregateException aex)
{
string messages = "";
foreach(Exception ex in aex.InnerExceptions)
{
messages += ex.Message + "\r\n";
}
MessageBox.Show(messages);
}
So I suggest you do this to see what is causing the problem
Please, remove your app from your device, Settings - Applications- Uninstall, this works for me. The Auth Object was crash in debug mode.Clean and Rebuild can be Helpfull to.
my problem is that I want to check that an element is not displayed. In other words I want to check that an element was deleted.
So I am developing an automatic test that has a option to disable comments. I want to check that the textfield for the comments is nonexistent. Is there any easy way to do this?
You need to distinguish between the element (a text field or something) being not displayed and it being empty.
If the field is displayed but is empty then a simple assertion that the value is the empty string will work.
If the field is not displayed at all then an attempt on an assertion will fail with a control not found exception. The relevant code can be enclosed within a try-catch block that expects to catch the exception
try {
... access the control...;
Assert.Fail("The control was found but it should not be present.");
}
catch (UITestControlNotFoundException ) {
// Success path.
}
Make sure that the ... access the control...; checks for the correct level in thy control hierarchy. You may also want to enclose it with code to fail quickly when the control is not present, by default Coded UI may wait in case the application is slow to draw the control.
Try this :
Bool isExists = (Boolean)BrowserWindow.ExecuteScript("return $('#yourcontrolId').length > 0;");
if(isExists)
Assert.Fail("Control is not deleted");
// Success Code