I have the following code:
<p:remoteCommand name="navigateTo" actionListener="#{searchControllerHelper.dummyActionListener}"
action="#{searchControllerHelper.navigateTo}" update="searchPanelForm"
onstart="plsWaitDlg.show()" onsuccess="plsWaitDlg.hide()"/>
Controller Code as under:
Thank you Lars. Code of the bean as under:
public String navigateTo() throws FetchException {
if (null == this.getSelectedMenuLink()) {
return null;
}
if (this.getSelectedMenuLink().longValue() == 1L) {
this.prevSelectedMenuLink = this.selectedMenuLink;
this.location = null;
return searchCRE();
}
else if (this.getSelectedMenuLink().longValue() == 2L) {
this.prevSelectedMenuLink = this.selectedMenuLink;
this.selectedLoanType=null;
return searchLoans();
}
else if (this.getSelectedMenuLink().longValue() == 3L) {
this.prevSelectedMenuLink = this.selectedMenuLink;
this.selectedLoanType=null;
return searchLoans();
}
else if (this.getSelectedMenuLink().longValue() == 4L) {
this.prevSelectedMenuLink = this.selectedMenuLink;
return otherOpportunities();
}
else if (this.getSelectedMenuLink().longValue() == 5L) {
//The link needs to be 'activated' once a service provider is selected.
this.prevSelectedMenuLink= this.selectedMenuLink;
return this.navigateToHome();
}
return null;
}
I added the actionlistener to check if the controller was getting fired or not, and it is.
What is happening is the following: The page loads, and before it is completely done loading if the user clicks the button that calls this remoteCommand then strangely the actionListener gets called, but the action method does not.
Any ideas what I could do to alleviate this issue?
Thank you
Karthik
Related
Hello i have this method
private ActionResult CheckResult(ReactivationResponse result, GlobalObject globalInfo)
{
if (result == null)
{
return RedirectToAction("Failed", "Redirect", new { errorCode = 1014 });
}
else if (!result.IsReactivationSuccess && !result.IsOrderImported && !globalInfo.MemberInfo.IsWinbackAplicable)
{
return RedirectToAction("Failed", "Redirect", new { errorCode = 201 });
}
else if (!result.IsReactivationSuccess && result.Errors.Any())
{
if (result.Errors.Any(e => e.Message == "ApprovalPending"))
{
return View("Pending");
}
return RedirectToAction("Failed", "Redirect", new { errorCode = result.Errors.FirstOrDefault().StackTrace });
}
return null;
}
inside another Action Result
public ActionResult OtherMethod()
{
CheckResult(result, globalInfo);
//More code
return View()
}
I'm trying to redirect the code according to the result, and in case it doesn't apply, that the app continue and return the normal view.
But it doesn't work, if any of the if statements applies it doesn't redirect to anywhere, it continues with the normal viw.
I also tried to put a return before the method
return CheckResult(result, globalInfo);
and it works except if my method returns null, then it doesn't continue with the app.
I want to evaluate if it needs to redirect or if it should continue
This my process screen:
as you can see it throws errors but it doesnt indicate the error mark on the grid.
After clicking the process button, it just unchecks the checkbox in my records
i want the grid to be like this(with the red 'x' mark):
this is my graph :
public PXCancel<PayrollFilter> Cancel;
public PXSetup<PayrollSetup> PayrollSetup;
public PXFilter<PayrollFilter> Filter;
[PXFilterable]
public PXFilteredProcessingJoin<PayrollEmployeeProcess, PayrollFilter,
InnerJoin<EPEmployee,
On<PayrollEmployee.employeeID, Equal<EPEmployee.bAccountID>>,
InnerJoin<Branch,
On<EPEmployee.parentBAccountID, Equal<Branch.bAccountID>>>>,
Where<PayrollEmployee.payPeriodID, Equal<Current<PayrollFilter.payPeriodID>>,
And<Branch.branchID, Equal<Current<AccessInfo.branchID>>>>> EmployeePayrollProcess;
#region Constructor
public PayrollProcess()
{
PayrollSetup setup = PayrollSetup.Current;
EmployeePayrollProcess.SetSelected<PayrollEmployeeProcess.selected>();
EmployeePayrollProcess.SetProcessDelegate(delegate (List<PayrollEmployeeProcess> employees)
{
if (Filter.Current == null) return;
var payPeriod = Filter.Current.PayPeriodID ?? 0;
var payrollPeriod = Filter.Current.PayrollPeriodID ?? 0;
if (payPeriod == 0 || payrollPeriod == 0) return;
PXLongOperation.StartOperation(this, delegate ()
{
bool errorOccured = false;
foreach (PayrollEmployeeProcess employee in employees)
{
PayrollRegisterEntry graph = PXGraph.CreateInstance<PayrollRegisterEntry>();
try
{
graph.ProcessPayroll(employee, payPeriod, payrollPeriod);
PXProcessing<PayrollEmployeeProcess>.SetInfo("Employee processed");
}
catch (Exception ex)
{
errorOccured = true;
//employees.IndexOf(employee),
PXProcessing<PayrollEmployeeProcess>.SetError(ex);
}
finally
{
graph.Clear();
}
}
if (errorOccured) throw new PXException("At least one employee was not processed.");
});
});
// EmployeePayrollProcess.
}`
can anyone can help me? I'm using Acumatica 6
Throwing an exception in Acumatica sets the error in the header. To set a Row or Field level error you need to set/raise it. There's a few ways to set/raise errors, what they have in common is that they don't use the 'throw' keyword.
For a processing screen with a filter, use the following syntax to raise the error:
PXFilteredProcessing<GridDetailDAC, GridFilterDAC>.SetError(rowIndex, new PXSetPropertyException("Error Message", PXErrorLevel.RowError));
Processing screen without filter:
PXProcessing.SetError(rowIndex, new PXException("Error Message"));
I am trying to fire a command to close my page after finalizing the execution of a method. However, the Close() command is not working.
According to the code below, how do I close my view after finishing the method execution?
My Model:
public IMvxCommand BtnSaveCommand
{
get
{
return new MvxAsyncCommand(updateOrder);
}
}
private async Task<bool> updateOrder()
{
var errors = validator.Validate(this);
if (!errors.IsValid)
{
messageService.showMessage(errors);
return false;
}
var responseEdit = await orderService.update(configureOrder());
if (responseEdit == null)
{
messageService.showMessage("Pedido " + Item.id + " foi editado com sucesso.");
configureUpdateItem();
//Close View
Close(this);
}
else
{
messageService.showMessage((IErrorCollection)responseEdit);
}
return true;
}
--Update
Adding more information, when triggered the Close(this) command I get the following error:
Mvx: Warning: 325,38 Do not know how to close this viewmodel - topmost view does not present this viewmodel
You need to call DismissViewController() on the NavigationController
I get the following exception when trying to access a relationship document:
java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to com.orientechnologies.orient.core.record.impl.ODocument
via:
Collection<ODocument> field = myDoc.field("MY_FIELD_NAME");
if(field != null) {
return field;
} else {
return Collections.emptySet();
}
The strange thing is that is happes not always, most of the time it works like expected.
Depending by what the field contains, you could use the interface OIdentifiable instead of ODocument.
Try using:
Collection<OIdentifiable> field = myDoc.field("MY_FIELD_NAME");
if(field != null) {
return field;
} else {
return Collections.emptySet();
}
I have a simple application. When a user logs in it creates a session variable and redirects them to another controller that pull up some info from the database. I need to store this to a session variable then return it to the view. The initial part is fine, it returns it and I see the information. However, when I try to create a search query it returns that the session is null even though I never clear it.
public ActionResult ShowCourses()
{
if (Session["Username"] != null)
{
string Username = Session["Username"].ToString();
using (DefaultConnection db = new DefaultConnection())
{
var model = from c in db.Courses
where c.Username == Username
select c;
Session["Courses"] = model.ToList();
var Courses = Session["Courses"];
return View(Courses);
}
}
else
{
return RedirectToAction("Login", "Users");
}
}
But when I try to run a search query to loop through the session, it brings back that Courses is null. The problem is that coursesQuery returns null and I'm not sure why.
public ActionResult SearchCourses(string query)
{
if (Session["Username"] != null)
{
var coursesQuery = Session["Courses"] as IEnumerable<Course>;
if (coursesQuery != null)
{
// Do Something
}
}
}
You did a .ToList() on the course colleciton before setting to Session.
Try this. Use List<Course> when you read it back.
if (Session["Courses"] != null)
{
var coursesQuery = (List<Course>) Session["Courses"];
}