React Native Navigation in a stateless component - react-native-navigation

I am trying to create stateless component and I am struggling with the navigation and got this error , " undefined is not an object "

I don't understand what you mean by stateless component, but your error seems to be from this.props.navigation being undefined. Check the code where you wrote
<QRCodeCamera />
It should have a prop called navigation like this
<QRCodeCamera navigation={navigation} />

Related

Updating an UI value from javascript is not getting reflected in javabean

I am trying to update an UI text field in primefaces 6.2 using java script method. Though I am able to update the value from UI side, it is not reflecting in backing managed bean
Xhtml:
<h:inputHidden id="test" value="#{mybean.fieldname}" valueChangeListener="#
{mybean.method}">
<f:ajax/>
</h:inputHidden>
Javascript:
function update(){
document.getElementByID('form:test').value="change";
alert(document.getElementByID('form:test').value);
}
I expect my value changehandler to get called since I updated my value but nothing occurs.can some one pls tell where I am getting wrong
Edit :Actually I am trying to submit the value changed from UI side alone using Js to the actual bean value, basically dom alone is changed and kind of trying to submit the same using any ajax calls. but still it is not working. Refered this link:When to use valueChangeListener or f:ajax listener? Can some one pls give some insights on how this can be achieved?
You have to trigger explicitly a change event by JavaScript if you set a value by JavaScript.

Update attribute in JSF custom component expect full element ID path where as direct PrimeFaces component runs with short element ID path

I am using <p:commandButton> tag with update attribute and passing current element ID in update attribute as currentForm: messages. something like: update="currentForm: messages". Where messages is the id of <div> element which I want to update after request call.
This is working fine.
Now I created a composite component with the same command button as we have in main template and replaces that PrimeFaces command button with created custom command button. (for now no any custom changes made in created command button just prime faces command button in this)
When I rendered the template it is complaining me about the ID given update attribute error given as:
javax.faces.FacesException: Cannot find component with expression "currentForm
and if I give full element ID path for this element it works again.
Although it is good if we give full element ID path to the element, but it surprise me why it is working when I am calling direct PrimeFaces command button ?
That's because composite components are like <h:form>, <h:dataTable>, etc also naming containers. Their effect on ajax client IDs is outlined in this related question: How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar".
This is done so because you otherwise run into "duplicate component ID" errors on composite component's implementation when reusing the composite component more than once in the same naming container parent. See also this related question: Should a composite component really require namingcontainer interface?
If you're absolutely positive that the composite component is the right solution for the concrete requirement and thus not a tagfile (a lot of starters namely overuse composite components due to their zero-configuration nature, while it should really best only be used if you intend to bind a single model property to a bunch of closely related components), then you may consider the following alternative ways to update the messages component:
Either dynamically pass the target client ID:
<my:compositeButton ... update=":#{messages.clientId}" />
...
<p:messages binding="#{messages}" ... />
(note: the code is as is; you don't need to bind it to a bean property or so!)
Or just let PrimeFaces auto-update the messages component on every ajax request:
<my:compositeButton ... />
...
<p:messages autoUpdate="true" ... />

Why is InputHidden readonly attribute not in JSF documentation?

I have recently encountered a case where I wanted to set the index value from ui:repeat varStatus="v" using <h:inputHidden="#{v.index}/>. If you try this and execute the component using AJAX you will get an exception that the property is not writeable. While looking around I found that inputHidden supports a readonly="true" attribute that does just that making the error go away.
Is there a reason why this is not in documentation? (i.e. special, passthrough, other)
Is it safe to use?
After doing some digging Core JavaServer Faces 3e had this to say :
The h:inputHidden tag has the same attributes as the other input tags, except that it does not support the standard HTML and DHTML tags
So, the reason why readonly is not in the docs for inputHidden and also why it's not being rendered in your HTML is because inputHidden does not support it. This was also confirmed by Netbeans when I tried to add readonly as an attribute to inputHidden'(red squiggly lines with an error message). I was able to get that exception when I submitted a form with no setter defined for my bean property that was placed in inputHidden. Since inputHidden calls the setter when a form is submitted (for my case) and since none is defined in my code, it will of course throw that exception, namely:
javax.el.PropertyNotWritableException: /index.xhtml #14,56 value="#{bean.x}": The class 'Bean' does not have a writable property 'x'.
As for why it works when you do that I have no idea. Since you're worried about safety, I would suggest you do as BalusC says and simply use <input type="hidden"> or you define a setter for that property. Don't use it like that.
So long time since this question started, however just FYI, this works:
<h:inputHidden id="compId" readonly="#{true}" value="#{myBean.attribute}" />

JSTL functions is not found in JSF

I am trying to add an active class on the page the user is currently viewing but I can't manage to use the JSTL functions. What am I doing wrong?
xmlns:fn="http://java.sun.com/jstl/functions"
Using this in a h:link
styleClass="#{fn:containsIgnoreCase(request.requestURI,'index') ? 'active' : ''}"
causes this error:
styleClass="#{fn:containsIgnoreCase(request.requestURI,'index')}" Function 'fn:containsIgnoreCase' not found
You've got wrong import, it should be :
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
You forgot about /jsp

Populate by code SelectOneMenu based on custom meta-data in attributes

I need a solution to populate by code SelectOneMenu using some meta-data specified as an attribute to this component.
Here is the detail of my requirement.
1) The developer would specify some thing like this:
<h:selectOneMenu id="someComponent" value="#{someController.someModel.someField}">
<f:attribute name="entity" value="somepackage.SomeEntity" />
</h:selectOneMenu>
2) When the page containing the above is requested for the first time, the server should be able to read the 'entity' attribute
3) Once the 'entity' is read, the server will do the needful to populate dynamically 'someComponent'.
I have no issue with the code that should use the 'entity' attribute and generate the content to be show in 'someComponent'. My issue is to found the appropriate place to call efficiently this code.
I have tried the PhaseEventListener for 'After Render Response Phase' but with no luck. It looks like I'm missing something fundamental as I'm new to JSF.
Have someone went through the same experiment?
Thank you in advance.
Younes Ouadi
If you target an EL 2.2 container which supports invoking methods with arguments and/or supply JBoss EL with your webapp so that it works on EL 2.1 as well, then it should be possible with the following construct:
<h:selectOneMenu id="someComponent" value="#{someController.someModel.someField}">
<f:selectItems value="#{someProvider.selectItems('somepackage.SomeEntity')}" />
</h:selectOneMenu>
with
public List<SelectItem> getSelectItems(String className) {
// ...
}
I'd introduce some lazy loading and/or request-based caching mechanism as well as a getter can be called more than once during bean's life.

Resources