I have a validation Rule in the remove row method with error message, but this message appear only when clicked delete row twice instead of one.
I don't know what's the cause of this issue, any help please.
public void remove() {
RowIterator rs = getStStore();
if (rs.getRowCount() > 0) {
ResourceBundle bundle = ResourceBundle.getBundle("model.AsconBundle", ADFContext.getCurrent().getLocale());
throw new JboException(bundle.getString("DELETE_MASTER_DETAIL_VALIDTION"));
} else {
super.remove();
}
}
Related
I have to iterate List through foreach loop and need to click on item. First item of the list is getting clicked but from second item onwards i am getting
org.openqa.selenium.StaleElementReferenceException: stale element
reference: element is not attached to the page document
public void checkFlightAvailabilityToSelectOutBound() throws InterruptedException {
boolean enabledFound=BookDateFlight();
System.out.println("checkFlightAvailabilityToSelectOutBound "+enabledFound);
if(enabledFound==false)
{
List<WebElement> nextAvailableDateList = driver
.findElements(By.xpath("somexpath"));
System.out.println("date list lenth "+nextAvailableDateList.size());
**for (WebElement nxtAvlDate : nextAvailableDateList)
{
try {
System.out.println("------"+nxtAvlDate);
System.out.println("Trying to click on the nxt avl date "+nxtAvlDate.getAttribute("id"));
//wait.until(ExpectedConditions.elementToBeClickable(nxtAvlDate));
//driver.navigate().refresh();
Thread.sleep(3000);
nxtAvlDate.click();
Thread.sleep(5000);**
//wait.until(ExpectedConditions.visibilityOfAllElements(flightInfoOutBoundTravelClassBtnList));
}catch(Exception e) {
e.printStackTrace();
System.out.println("message catch"+e.getMessage());
}
enabledFound=BookDateFlight();
System.out.println("After clicking nxt avil date "+enabledFound);
if(enabledFound==true)
{
break;
}
}
if(enabledFound==false)
{
System.out.println("inside next 7 day");
driver.findElement(By.xpath("//p[#class='next']")).click();
System.out.println("inside next 7 day clicked");
Thread.sleep(10000);
checkFlightAvailabilityToSelectOutBound();
}
}
}
In case of staleelementexception the problem is generally due to the fact that a reference is requested to an element that has been updated or is new (even if maybe it has the same id) and therefore we have an invalid reference to it. It can be solved by asking for a clean reference of the item or adding a wait in the workflow
You can try something like this:
WebDriverWait wait = (WebDriverWait)new WebDriverWait(driver,timeout)
.ignoring(StaleElementReferenceException.class);
wait.until(new ExpectedCondition<Boolean>(){
#Override
public Boolean apply(WebDriver webDriver) {
WebElement element = webDriver.findElement(by);
return element != null && element.isDisplayed();
}
});
Adapting it to you code
it usually occurs when the dom is getting refreshed .try the following explicit wait before doing the click
wait.until(ExpectedConditions.stalenessOf(nxtAvlDate));
I've Created a Model which have few custom validation. These custom validation I've annotated at property by below code
[CustomValidation(typeof(ItemmasterModel), "ValueTextMaxLenghtValidate")]
public decimal Valuetextmaxlength
{
get
{
return _Valuetextmaxlength;
}
set
{
ValidateProperty("Valuetextmaxlength",value);
_Valuetextmaxlength = value;
RaisePropertyChanged(() => Valuetextmaxlength);
}
}
public static ValidationResult ValueTextMaxLenghtValidate(object obj, ValidationContext context)
{
var itmmstr = (ItemmasterModel)context.ObjectInstance;
if (itmmstr.SelectedValuetypeDd != null)
{
string vtype = itmmstr.SelectedValuetypeDd.Key.ToString();
if (vtype.Equals("C"))
{
if (itmmstr.SelectedItemValueCodeTypesDd != null)
{
string vcode = itmmstr.SelectedItemValueCodeTypesDd.Key.ToString();
if (vcode.Equals("T"))
{
if (itmmstr.Valuetextmaxlength == null || itmmstr.Valuetextmaxlength == 0)
{
return new ValidationResult("Value Max Length is not Entered",
new List<string> { "Valuetextmaxlength" });
}
}
}
}
else if (vtype.Equals("T"))
{
if (itmmstr.Valuetextmaxlength == null || itmmstr.Valuetextmaxlength == 0)
{
return new ValidationResult("Value Max Length is not Entered",
new List<string> { "Valuetextmaxlength" });
}
}
}
return ValidationResult.Success;
}
Now this validation code depend on other property. scenerio When User select a value from dropdown it makes 1 checkbox selected automatically and User should enter the value in texbox also.
Issue:
Validation is working. checkbox is selected at first time then also it comes with error popup.
untill user doesn't make changes into this checkbox or texbox it is with error only. 1 time it says error even value has been entered .Next time it goes even user have not entered anything but during final full object validation is again comes with error.
Why this even ambiguity is happening. How to solve this.
Need more code let me know. I'll Post. Code is in Silverlight 5, MVVM Light
During my Custom validation I was using ValidateProperty("Valuetextmaxlength",value); before setting the value of property so It was giving me issue but the moment I set the value first and then Use my ValidateProperty("Valuetextmaxlength",value); everything worked smooth. Still I don't know the reason why but It worked for me.
I've a listener on cellClick, I get the selected Record but I can't find a way to understand if this record is checked
Method ListGrid.isSelected(ListGridRecord) returns true if row is selected, not if is checked
My Code:
listGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
listGrid.addCellClickHandler(new CellClickHandler() {
#Override
public void onCellClick(CellClickEvent event) {
if(event.getColNum() == 0 && idMenu != null){
boolean isChecked = event.getRecord().???;
if(isChecked)
....
else
....
}
I've tried also with event.getRecord().getAttributeAsBoolean("_checkField") with no success...
I found a simply solution...
My task is solved using a special boolean field in the DataSource named, for example, "checked"
In ListGrid I've a field "checked", and with a RecordClickHandler I can manage check or uncheck event.
DataSource code:
DataSourceBooleanField checkField = new DataSourceBooleanField("checked");
ListGrid code:
listGrid.addRecordClickHandler(new RecordClickHandler() {
#Override
public void onRecordClick(RecordClickEvent event) {
Record rec = event.getRecord();
boolean checked = rec.getAttributeAsBoolean("checked");
if(checked){
...
}else{
...
}
rec.setAttribute("checked", !checked);
catPgrid.saveAllEdits();
catPgrid.refreshFields();
}
});
ListGridField checkField = new ListGridField("checked", "Sel");
Maybe getSelectedRecords() method would help you!
Here is an API reference: http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGrid.html#getSelectedRecords()
Definitely this will provide all records which are selected (using checkbox) but there should be some values which you could use for identifying each record uniquely!
There is form with text element that should receive focus every time form shown.
In .NET CF Form has no OnShow(n) event
I try to use workaround:
MyForm_GotFocus() // or MyForm_Activated
{
txtTextControl.Text = string.Empty;
txtTextControl.Focus()
}
txtTextControl_GotFocus()
{
txtTextControl.SelectAll()
}
Code for getting form instance:
public static MyForm GetForm
{
get
{
if (s_inst == null || s_inst.IsDisposed)
{
s_inst = new MyForm();
}
return s_inst;
}
}
public static void ShowForm()
{
var frm = GetForm;
frm.Show();
}
1) First time ShowForm (Form instance has been created): txtTextControl emptied and got focus, txtTextControl_GotFocus event raised
2) Second time ShowForm : OK too
3) Third time ShowForm : txtTextControl emptied, but does not get focus
Is there bug or feature? Is there workaround? Show I rewrite ShowForm? Is OpenNETCF.IOC.UI is better solution (50 forms in project)?
I had that same question once.
Set the TabIndex for the control to 0.
I am using the WPF webbrowser and basically when I load an external url, i want to filter any pages that are loaded to make sure the url doesnt contain a swear or porn type word.
This is easy to do on page load, as I check the URL against my List badwords; I have also set up a Load Completed method which gets me the url of clicked words, however this isnt working properly :-
void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)this.webBrowser1.Document;
foreach (IHTMLElement link in doc.links)
{
HTMLAnchorElement anchor = link as HTMLAnchorElement;
if (anchor != null)
{
HTMLAnchorEvents_Event handler = anchor as HTMLAnchorEvents_Event;
if (handler != null)
{
handler.onclick += new HTMLAnchorEvents_onclickEventHandler(delegate()
{
uxURLText.Text = anchor.href;
//if (HelperClass.isNotFile(anchor.href))
// {
if (basepage.nonSafeWords.WordsContainSwearWord(anchor.href))
{
System.Windows.MessageBox.Show(basepage.INTERNET_RESTRICTION_NOTICE);
}
else
{
System.Windows.MessageBox.Show("Word Ok");
}
return true;
});
}
}
}
}
I need to basically stop any bad content from loading in the window, either from link, button, or ajax if a bad link is clicked a popup needs to notify us. I also need to show the current url in the address bar
Please help many thanks
:)
Listen to the WebBrowser.Navigating Event (docs) and check the Uri in NavigatingCancelEventArgs. Then set e.Cancel = true if you to not want to allow the navigation.
But your valid Uri check is the more complex problem.
private void webBrowser1_Navigating(object sender, NavigatingCancelEventArgs e)
{
string currentURl= e.Uri.ToString();
_addrBox.Text = currentURl;
}
this was the solution in my case.
maybe itll help somebody