1

I want to clear form hidden value in JSF page from managedbean class .so i used to call a method in that i used this code to call javascript but it throws java.lang.NullPointerException below is the code.

FacesContext facesContext = FacesContext.getCurrentInstance();
    ExtendedRenderKitService service = 
              Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
            service.addScript(facesContext, "alert('foo');");

the error is thrown in the line where alert is called .can someone help me please.even i tried to call a function in JSF page to reset values...it gave me same error.

user2644886
  • 31
  • 1
  • 1
  • 5
  • At which line is the NPE thrown ? – Konstantin Yovkov Oct 11 '13 at 09:30
  • @kocko In last line service.addScript(facesContext, "alert('foo');");..when i call javascript. – user2644886 Oct 11 '13 at 09:33
  • Not enough information. I am assuming that you are working with ADF / Trinidad. Can you provide details of how the form field is setup in your page? You can probably look at a simple solution like setting a partial trigger or adding the component from the managed bean code itself. – Harsha R Oct 11 '13 at 10:28
  • @user2644886........I guess you have to cast it as `ExtendedRenderKitService` Class as shown in this example.http://svn.apache.org/repos/asf/myfaces/trinidad/trunk/trinidad-examples/trinidad-blank/src/main/java/org/apache/myfaces/trinidad/blank/HelloWorldBacking.java – SRy Oct 11 '13 at 13:10

3 Answers3

1

if you use primefaces,you can use Request Context component of primefaces.

RequestContext

if you dont want ,you can check this out

without primefaces

Community
  • 1
  • 1
mstzn
  • 2,881
  • 3
  • 25
  • 37
0
RequestContext.getCurrentInstance().execute("jsMethod();");

RequestContext.getCurrentInstance().execute("$('#ID').hide();");

RequestContext.getCurrentInstance().execute("PF('WIDGET').show();");

You can execute any javascript/jquery/primefaces code inside execute method.

-1

You can use Request Context component of primefaces

Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51