Win a copy of OCP Java SE 8 Programmer II Exam Study Guide this week in the OCP forum!

Himai Minh

Ranch Hand
+ Follow
since Jul 29, 2012
Cows and Likes
Cows
Total received
10
In last 30 days
0
Total given
0
Likes
Total received
66
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Himai Minh

Hi,
What is the difference between NoneScoped and RequestScoped?
According to Stackoverflow's comments, a none scoped bean lives as long as the EL expression is evaluated. But when the none scoped bean's EL expression is evaluated in one request/response, it has already gone through the lifecycle such as restore view, apply request, process validation, update model, invoke application , render response.
And a request scoped bean has to go through all the cycle in one request/response.
1 week ago
JSF
I recently ran an example (https://github.com/jsflive/jsf22-examples/tree/master/jsf22-composite-component-tags):

There is a resources/util/panelBox.css in the root directory.
The composite is displayed, but the style in panelBox is not.
2 weeks ago
JSF
Hi, I am running the cdiviewscope example developed by Michael  Kurz at https://github.com/jsflive/jsf22-examples/tree/master/jsf22-cdi-view-scope
I used JDK 1.8 and Glass fish 4.1.






Glassfish gives me this error when the jsf application is deployed:


cannot Deploy cdiviewscope
deploy is failing=Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type PersonRepository with qualifiers @Default
  at injection point [BackedAnnotatedField] @Inject private at.jsflive.jsf22.cdiviewscope.PersonPage.personRepository
  at at.jsflive.jsf22.cdiviewscope.PersonPage.personRepository(PersonPage.java:0)
. Please see server.log for more details.

3 weeks ago
JSF
But the problem is that in the Next.xhtml, bar = #{flash.foo} does not do anything.
I have to put bar = #{flash.now.foo} to make it work.
1 month ago
JSF
In the API of javax.faces.context.Flash (https://docs.oracle.com/javaee/7/api/javax/faces/context/Flash.html), it says:


  First page

    <h:button id="nextButton" value="Next (button)" outcome="next.xhtml">
      <f:param name="foo" value="bar"/>
    </h:button>

    Next page

    <html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:f="http://xmlns.jcp.org/jsf/core"
          xmlns:h="http://xmlns.jcp.org/jsf/html">
    <f:metadata>
      <f:viewParam name="foo" id="foo" value="#{flash.now.foo}" />
    </f:metadata>
    <head /><body>
    foo = #{flash.foo}
    </body>
    </html>



I think the Next page should have instead.
When I ran this Next page, it does not print #{flash.foo} on the screen.
1 month ago
JSF
Hi, Tim.
Thanks for your suggestion. I just simply remove the index from the array without recreating a new ArrayList. It works on my side.


The reason why I don't use nameDataModel to remove because ListDataModel class does not have remove method.
1 month ago
JSF
Hi, Tim. Thanks for your suggestion.
I need to convert the Name[] into ArrayList<Name> in order to remove the selected index.
The code is:

The index.xhtml:
1 month ago
JSF
Tim,
Thanks for your explanation.
I modify the chapter 6 delete example in Core JSF.


In index.xhtml, we can click on the Delete link to delete one name at a time

1 month ago
JSF
Hi, I just notice ArrayDataModel does not have remove method. So, what should we do if we want to remove elements in ArrayDataModel?
This is an example of the Core JSF :


If we have and we wrap it in ArrayDataModel like this:


How can we remove a name from the data model since there is no remove method in ArrayDataModel?

2 months ago
JSF
I tried this example with <!-- <hutputText value="#{user.amount}" /-->, where amount >10.00
The exception is thrown after the restore view phrase and before the render response phrase:


BEFORE RESTORE_VIEW 1
2018-03-21T20:06:08.063-0400|Info: AFTER RESTORE_VIEW 1
2018-03-21T20:06:08.068-0400|Info: BEFORE RENDER_RESPONSE 6
...
javax.el.ELException: java.lang.RuntimeException: Invalid amount :11.0
...
Caused by: java.lang.RuntimeException: Invalid amount :11.0
at com.corejsf.User.getAmount(User.java:26)
...
2018-03-21T20:06:09.035-0400|Info: AFTER RENDER_RESPONSE 6



But if the user.amount is <10.00, the output is not  displayed and  the console printout is:


BEFORE RESTORE_VIEW 1
2018-03-21T20:14:07.503-0400|Info: AFTER RESTORE_VIEW 1
2018-03-21T20:14:07.509-0400|Info: BEFORE RENDER_RESPONSE 6
....
2018-03-21T20:14:08.671-0400|Info: AFTER RENDER_RESPONSE 6

So,  in <!--<hutputText value="11.0"> -->,
you mean there is an exception thrown in the apply request phrase, the response is completed. And the response is the exception.
But in <!--<hutputText value = "5.0"> --> ,
there is no exception thrown in the apply request phrase, the response is rendered. But since the response is commented out, it is not display.

Correct me if I am wrong.
Hi, I am just curious why the exception is displayed on the screen even though the outputText is commented out while the value is not displayed in this case ?
For example, if the value is 5.0 after JSF processed the expression, it is not displayed because of <!-- -->.
But if the value is 11.00 after the JSF throws the exception, the exception is still displayed even though the outputText has <!-- -->.
Why the exception is printed?
Hi, Prasad,
I tried your nice example about the amount > 10.0.
If the amount > 10.0, it throws the exception even though with the output text commented out in XML <!-- <hutputText value="#{user.amount} ... -->
But if the amount is not 10.0, it does not display anything with <!-- -->
So, does it mean the outputText is processed or not  with <!-- -->?
Here is a tip :
If we have this:


The data table won't be displayed because the ui:composition trim everything outside it. Since the data table is outside ui:composition, the table won't be display.
Only whatever inside ui:composition is displayed. In this case, it does not  "see" the #{address} variable, so it does not show the address.

I think comment out is important for this exam.
To comment out a statement in xhtml, <!-- --> is used. Also do one of these:
1. In web.xml, add this context param:
<context-param>
   <param-name>facelets.SKIP_COMMENTS</param-name>
   <param-value>true</param-value>
</context-param>

2. <ui:remove> ... something you want to comment out</ui:remove>

Without one of these, <!-- comments --> still appears in the generated html even though the comment is not displayed in the xhtml.