Scrolling of Tableview is crashing the Monotouch based iOS App - xamarin.ios

Hi i am right now developing a custom cell based tableview by using Monotouch.
The table view is showing data properly in custom cell.
But when i tried to scroll the table view, it is crashing the app.
Error Message:-
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
Name: NSInvalidArgumentException Reason:
-[__NSCFSet tableView:cellForRowAtIndexPath:]: unrecognized selector sent to instance 0xfd50430
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at OrderManagementSystem.Application.Main (System.String[] args) [0x00000] in /Users/administrator/Documents/xyz/dlds/OMS/OMS/Main.cs:17
Also i am not able to catch the method where it is crashing even though i enable the breakpoint.
How can i fix this problem?

Related

FacesException not being handled by standard error page

there is one issue to which i don't find any specific answer. there is an ArrayOutOfBoundException thrown in a setter method called during render response phase since i have the value of that property set in my faces-config. Now, when this happens, it is not redirecting. What i could understand till now is it might be converting this exception to FacesException and so its not redirecting. Any views to handle this ? the call does not seem to be an ajax call too since it is coming when i click on a menu item.

Liferay: what is the relationship and difference between ActionRequest, RenderRequest and PortletRequest?

What is the relationship and difference between ActionRequest, RenderRequest and PortletRequest?
Can we get instance of one from another?
The PortletRequest is the parent of both. An ActionRequest and a RenderRequest are both different types of PortletRequest objects.
An ActionRequest is valid during the action processing phase of the portlet. During this phase, the portlet hasn't completely decided how it is going to render itself, be it minimized, maximized, in edit mode or in veiw mode, etc.
On the other hand, the RenderRequest is valid during the rendering phase of the portlet. At this point, the portlet knows how it is going to render itself, and certain changes such as window state, are not allowed.
If you want to pass the params from action to render, you would need to set the ActionResponse using
response.setRenderParameter(key,val);
Then this is available in the corresponding RenderRequest.
Answer was found here

JSF 2 - Using a custom action-listener to reset ajax submitted values so new values are pulled from model attributes

I'm using JSF 2 Mojarra, RichFaces 4.1, and EL 2.2, deployed to a Tomcat 7 server.
On my page, I have two a4j:regions contained in the same form. The top region is a dataTable list of entities. The bottom region is a detail editor panel. You select an entity from the list, and its details load in the edit panel. The detail panel has its own validation rules and submit buttons. I've now run into the reasonably well-known issue of JSF not resetting the submitted values with validation errors when I load a second entity into the detail form.
In researching to solve this problem, I came across this blog from BalusC. He breaks the reset problem down very well and recommends this JSF 2 action-listener to solve the issue.
I incorporated the ResetInputAjaxActionListener into my project as a action-listener defined in my faces-config.xml. Now, however, the code is failing where without the listener, it is working (just not resetting the submitted/local/model values).
My JSF page contains a dataTable and each row has an edit commandLink to load the row's entity into the editor:
<a4j:commandLink action="#{editController.load(entity.id)}" render="#form" execute="#this" value="Edit"/>
Since I'm using EL 2.2, I'm passing the entity's primary key directly into the load method. Without the action-listener, this works as expected. However, when I enable the action-listener, the code throws the following exception:
Caused by: javax.faces.FacesException: #{editController.load(entity.id)}: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)
at com.buksoft.automaint.web.util.ResetInputAjaxActionListener.processAction(ResetInputAjaxActionListener.java:163)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at org.richfaces.component.RowKeyContextEventWrapper.broadcast(RowKeyContextEventWrapper.java:104)
at org.richfaces.component.UIDataAdaptor.broadcast(UIDataAdaptor.java:452)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
... 51 more
Caused by: javax.faces.el.MethodNotFoundException: java.lang.NullPointerException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:104)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 58 more
Caused by: java.lang.NullPointerException
at java.lang.Class.isAssignableFrom(Native Method)
at org.apache.el.util.ReflectionUtil.isAssignableFrom(ReflectionUtil.java:299)
at org.apache.el.util.ReflectionUtil.getMethod(ReflectionUtil.java:172)
at org.apache.el.parser.AstValue.invoke(AstValue.java:251)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 59 more
It looks to me like the the EL argument value is getting set to null, which is causing a NullPointerException when EL tries to bind null to the action method's parameter, which is expected an Long value.
Now for the part that's really got me stumped. To narrow down the error, I commented out the functionality of the ResetInputAjaxActionListener so that it was basically read-only. What I found is that if these lines of the findAndAddEditableValueHolders() method execute, then the exception is thrown by the ActionListenerImpl.processAction() called after the ResetInputAjaxActionListener completes:
if (target instanceof EditableValueHolder) {
inputs.add((EditableValueHolder) target);
}
else if (context.getIdsToVisit() != VisitContext.ALL_IDS) {
// Render ID didn't point an EditableValueHolder. Visit all children as well.
findAndAddEditableValueHolders(VisitContext.createVisitContext(
context.getFacesContext(), null, context.getHints()), target, inputs);
}
See the findAndAddEditableValueHolders() method in the ResetInputAjaxActionListener class linked above.
And the trouble code is really only in the else if, which really confuses me because it's a recursive call back to the method itself. It's almost if the createVisitContext() method is somehoe modifying the backing view tree. As I said, if I strip out all mutating code that makes any real changes, and just execute this tree visit code (read-only), the exception is thrown down the line.
Can anyone explain how visiting the component tree (and not modifying anything in it), could break the EL method argument functionality?

ViewExpiredException shown in java.lang.Throwable error-page in web.xml

I'm working on a JSF web application in which I need to bring up a "Session Expired" page if the view expires, but a general technical error page for all others. The application only goes to the technical error page when I trigger the exception. Here's the error-page definitions:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/jsps/utility/sessionExpired.jsp</location>
</error-page>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/jsps/utility/technicalError.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/jsps/utility/technicalError.jsp</location>
</error-page>
I removed the technicalError.jsp error page elements and it worked fine, but when I put them back I can't get to the sessionExpired.jsp page. How do I tell the web container the order to evaluate these tags so that the right page comes up? Thanks.
This is because the ViewExpiredException is been wrapped in a ServletException as per the JSF specification. Here's an extract of chapter 10.2.6.2 of the JSF 1.2 specification:
10.2.6.2 FacesServlet
Call the execute() method of the saved Lifecycle instance, passing the
FacesContext instance for this request as a parameter. If the execute() method
throws a FacesException, re-throw it as a ServletException with the
FacesException as the root cause.
How the error pages are allocated is specified in Servlet API specification. Here's an extract of chapter 9.9.2 of Servlet API specification 2.5:
SRV.9.9.2 Error Pages
If no error-page declaration containing an exception-type fits using the
class-hierarchy match, and the exception thrown is a ServletException or
subclass thereof, the container extracts the wrapped exception, as defined by
the ServletException.getRootCause method. A second pass is made over the error
page declarations, again attempting the match against the error page
declarations, but using the wrapped exception instead.
In class hierarchy, ServletException already matches Throwable, so its root cause won't be extracted for the second pass.
To prove this specified behaviour, replace javax.faces.application.ViewExpiredException by javax.servlet.ServletException as <exception-type> and retry. You'll see the expected error page being displayed.
To solve this, simply remove the error page on java.lang.Throwable or java.lang.Exception. If no one exception specific error page matches, then it will fall back to the one for error code of 500 anyway. So, all you need is this:
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/jsps/utility/sessionExpired.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/jsps/utility/technicalError.jsp</location>
</error-page>
Update: as per the (deleted) comment of the OP: to reliably test this you cannot do a throw new ViewExpiredException() in a bean constructor or method or so. It would in turn get wrapped in some EL exception. You can eventually add a debug line printing rootCause in the Filter to see it yourself.
If you're using Eclipse/Tomcat, a quick way to test ViewExpiredException is the following:
Create a JSF page with a simple command button, deploy and run it and open it in webbrowser.
Go back to Eclipse, rightclick Tomcat server and choose Clean Tomcat Work Directory. This will restart Tomcat and trash all serialized sessions (important! just restarting Tomcat is not enough).
Go back to webbrowser and press the command button (without reloading page beforehand!).
As mentioned by BylusC, deployment descriptor must not contain any error-page handler that will catch ViewExpiredException (wrapped inside ServletException) instead of the correct one - error-page for ViewExpiredException.
Do not forget to verify that server's deployment descriptor (e.g. TomEE/conf/web.xml) does not contain java.lang.Throwable or java.lang.Exception error-page definitions. Because these two web.xml are basically merged.
Yes - application's web.xml has precedence over server's web.xml, but if application's web.xml contains
error-page for 500 (/error.xhtml)
and server's web.xml for
500 (/500.html) and for
Throwable (/bigerror.html)
then application context will contain merge of those two:
500 (/error.xhtml)
Throwable (/bigerror.html)
and ViewExpiredExcpetion error handling will not work correctly.

After rich:extendedDataTable sortby, other actions are not getting executed

I have several tabs and one of the tabs uses rich:extendedDataTable. If sortBy is clicked in the page where table is used and if I navigate to another page, it looks for the bean of the old page and throws an error saying that sortyBy of the column is undefined.
E.g. If I use sortBy on userId in tab1 (where the column must have sortBy="#{data.userId}") and then I click on tab2, it looks for the data.userId and throws an error. I am using Richfaces version 3.2.2SR1.
Can anyone help me on this?
Here is the complete trace:
javax.el.PropertyNotFoundException: /amendapplication/historyDetails.xhtml #33,174 sortBy="#{data.statusChangeTime}": Property 'statusChangeTime' not found on type uk.gov.wales.rpd.domain.applicationmanagement.ApplicationAttributeEntity
com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:73)
org.richfaces.model.impl.expressive.ValueBindingExpression.evaluate(ValueBindingExpression.java:59)
org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapObject(ObjectWrapperFactory.java:189)
org.richfaces.model.ModifiableModel$RowKeyWrapperFactory.wrapObject(ModifiableModel.java:57)
org.richfaces.model.impl.expressive.ObjectWrapperFactory$2.convert(ObjectWrapperFactory.java:177)
org.richfaces.model.impl.expressive.ObjectWrapperFactory.convertList(ObjectWrapperFactory.java:138)
org.richfaces.model.impl.expressive.ObjectWrapperFactory.wrapList(ObjectWrapperFactory.java:175)
org.richfaces.model.ModifiableModel.sort(ModifiableModel.java:235)
org.richfaces.model.ModifiableModel.modify(ModifiableModel.java:206)
org.richfaces.component.UIExtendedDataTable.createDataModel(UIExtendedDataTable.java:310)
org.ajax4jsf.component.UIDataAdaptor.getExtendedDataModel(UIDataAdaptor.java:621)
org.ajax4jsf.component.UIDataAdaptor.setRowKey(UIDataAdaptor.java:339)
org.ajax4jsf.component.UIDataAdaptor.iterate(UIDataAdaptor.java:1034)
org.ajax4jsf.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:1158)
org.ajax4jsf.component.UIDataAdaptor.processDecodes(UIDataAdaptor.java:1168)
javax.faces.component.UIForm.processDecodes(UIForm.java:209)
org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:392)
org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:380)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
Look like as if you've bound multiple different datatables to the same UIData property, or that you're reusing the same bean property to supply different datamodels depending on the displayed tab/table.
You can and should not reuse the one and the same bean property for different components and/or different value purposes. Verify if anything is right in your beans.

Resources