Force jsf clientid

Hi,
I created a custom JSF 1.1 component. Just like the Tomahawk component set I would like to be able to force the clientId to be the value I specify in the id attribute of my custom tag using an extra 'forceId' attribute. This works fine when I don't use valuebinding for this id attribute. But it seems that valuebinding is not allowed for the id attribute because it is ignored when I use a value like 'xxx#{yyy}'. To fix this I assumed that I needed to modify my setProperties() method of my JSF UIComponentTag. But when using Facelets this class is never called: I guess because Facelets uses it's own TagHandler?
Why does Facelets ignore the valuebinding used in the id attribute?
Does anyone have a suggestion to deal with this problem? Do I have to create a custom TagHandler?
Thanks in advance!
Kind regards,
Dirk

Hi,
suppose I have the following HTML rendered:
<tr>
<td>
<input type="radio" id="form:tab1:tabSubForm1:choices:0:mc_choice1308" name="choices_question608" value="1308">
</input>
</td>
<td>
<img src="/Fysiquest/protected/documentServlet?id=12105" />
</td>
</tr>
<tr>
<td>
<input type="radio" id="form:tab1:tabSubForm1:choices:0:mc_choice1309" name="choices_question608" value="1309">
</input>
</td>
<td>
<img src="/Fysiquest/protected/documentServlet?id=12107" />
</td>
</tr>
if I want the radiobutton to be selected when the user clicks the image it seems more handy to me to only specify 'mc_choice1308' or 'mc_choice1309'. My page contains multiple tabs (cfr 'tab1') and I even can't render the '1308' or '1309' after the 'mc_choice' because JSF EL for the id attribute is not working. So, it does not matter if I just want 'mc_choice1308' or 'form:tab1:tabSubForm1:choices:0:mc_choice1308': I just want the JSF EL to work with the id attribute.
Kind regards,
Dirk

Similar Messages

  • Customized JSF clientid question

    Dear all,
    In the jsp jsf codes, I have the following customized component
    <dojo:dojoComboBox dojotype="dijit.form" binding="#{backing_GWANADD.dojoComboBox2}" id="dojoComboBox2"/>
    <a4j:commandButton binding="#{backing_GWANADD.commandButton1}"
    id="commandButton1" action="backing_GWANADD.makeResult" reRender="dojoComboBox2" value="submit"/>
    where dojo:dojoComboBox is customized components and a4j is the ajax4jsf component (command button).
    Please pay attention on a4j tag, attribue "reRender" was used to urge the component with id dojoComboBox2 to re-render data from backing bean.
    When I run the application, there is error that the id "dojoComboBox2" could not be found, showing the id of customized control is not dojoComboBox2.
    When I change the id from dojoComboBox2 to id0, it works. How can I change the ID from id0 to dojoComboBox2 ?
    If the id is not change from _id0 to the id that I set, I am not able to make use of the component id to do something.
    So, change customized jsf id is important to me. How to do it? Thank you.

    help................

  • How to create JSF UIComponent tree before rendering phase?

    Hello,
    The JSF lifecycle create the JSF UIComponent tree (I mean : parsing the JSP to buid the JSF component tree) during the restore phase if the request is a postback else during the render phase.
    In my application, I need to link JSF component with error message (coming from business layer) like :
    FacesContext.getCurrentInstance().addMessage("form1:v1", new FacesMessage("Test!"));To do that, the JSF component with the Id"form1:v1" must exist! And that not the case if the request is not a postback.
    A solution should be to build the JSF component tree just before the rendered phase by implementing the a custom PhaseListener. But i dont know how to force JSF to build the JSF component tree?
    Is it possible? Other solution?
    Thanks!
    JPL

    Sniff! no answer!
    May be I have to explain more my issue?
    JPL

  • Forcing a special order while using a panelTabbedPane

    Hello all,
    I have created a "panelTabbedPane" with 5 tabs. Every tab has it's own managed bean. The scope for each bean is declared as "request"
    After pressing a commandLink I want to collect the data entered into the tabs and store it to the database.
    CODE SNIPPPET OF THE JSP:
    <t:panelTabbedPane bgcolor="#FFFFCC" >
    <f:subview id="viewTab1" >
    <jsp:include page="./CreateBiddingTabCustomerData.jsp"/>
    </f:subview>
    <f:subview id="viewTab2" >
    <jsp:include page="./CreateBiddingTabIndividualText.jsp"/>
    </f:subview>
    <f:subview id="viewTab3" >
    <jsp:include page="./CreateBiddingTabOfferPositions.jsp"/>
    </f:subview>
    <f:subview id="viewTab4" >
    <jsp:include page="./CreateBiddingTabPaymentConditions.jsp"/>
    </f:subview>
    <f:subview id="viewTab5" >
    <jsp:include page="./CreateBiddingTabPreview.jsp"/>
    </f:subview>
    </t:panelTabbedPane>
              <t:commandLink
                   value="Collect"
                   action="#{TabCollectBean.getData}">
              </t:commandLink>
    The TabCollectBean gets the RequestMap like this:
    Map map = initialSetup.facesContext.getExternalContext().getRequestMap();
    Now you can loop through the Map and get each managed bean of the Tab,
    that's the assumption.
    THE PROBLEM:
    Yesterday the application was first going into each managed bean per tab and at the end the TabCollectBean was called. Today it's vice versa and nothing is working.
    How can I force JSF to call first the managed beans for the tabs???
    Thanks for all answers
    Mario

    I am trying to use <t:panelTabbedpane> but i am unable to use it
    i am trying myfaces1.1.2 jars and tomahawk1.1.2 jars
    is this version of myfaces support <t:panelTabbedpane>
    i am able to use use <t:inputDate> but unable to use <t:panelTabbedpane>
    my code is :::
    <t:panelTabbedPane bgcolor="#FFFFCC">
    <t:panelTab label="Tab 1">
    <f:verbatim><H1>Tab 1</H1></f:verbatim>
    </t:panelTab>
    <t:panelTab label="Tab 2">
    <f:verbatim><H1>Tab 2</H1></f:verbatim>
    </t:panelTab>
    <t:panelTab label="Tab 3">
    <f:verbatim><H1>Tab 3</H1></f:verbatim>
    </t:panelTab>
    </t:panelTabbedPane>
    i m getting message::::
    javax.faces.FacesException: org.apache.jasper.JasperException
         at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:425)
         at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:234)
         at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:300)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:95)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.myfaces.component.html.util.ExtensionsFilter.doFilter(ExtensionsFilter.java:122)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:213)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
         at java.lang.Thread.run(Thread.java:534)
    Pls help me by suggesting
    me that are the actual requirement for using this component and where is the probable area of error, and what i can do to make it running
    thanks in advance

  • Navigation handlers and user authentication

    I've implemented a system to force user logins based on the code demonstrated here: http://www.jsftutorials.net/jsfNavigation/jsf-login-navigation-redirect.html but I've come across a problem.
    It seems the navigation handler is called only when JSF needs to resolve the outcome of an action and this means that in certain cases a user can view a secure page without having to log in. For example, using the example app from the above link, if a user goes to the start page of the project and clicks on the command buttons to access the protected pages, they are re-directed to the login page as expected. However, if they go to the url of the protected page directly (eg http://localhost:8080/jsf-loginRedirect/secure/editUserProfile.jsf ) it still displays the page.
    Currently I've got a filter in place that re-directs the user to the login page of the web app if there isn't a valid user logged in, but as this runs outside a Faces context I can't track the user's requests.
    Is there some way I can force JSF to call the navigation handler for normal get requests?

    Chops,
    There are 2 things related to this issue,
    1. When the user goes out of the application, you must invalidate the session. So that the userid will not be present in the session.
    2. You can have a phase listener that checks for User Id in session, if the user id is empty, you can re-direct the user to login page. If user id is present automatically the control will go to the navigation rule page.
    Phase Listener will enforce the user authentication.
    Hope this logic helps you to solve the issue.
    Thanks
    Prakash

  • Programmatic changes to HtmlForm do not get rendered

    What I want to do sounds actually very simple:
    I have a form containing a button which when clicked should dynamically add new components (input field, text) to the form. These components are added programmatically in the backing bean method which is called when the button gets clicked.
    When checking the HtmlForm component in the debugger these objects properly appear in childrenList of the form object and they add up there when clicking the button multiple times.
    The problem is, that the created components never appear on the page in the browser. I've been looking now for quite some time but didn't find any solution to this problem. It seems that the renderer just doesn't know that the component tree has changed. Do I have to notify the JSF framework/the renderer/whatever somehow to refresh the view?
    Calling facesContext.renderResponse(); in addRow() doesn't make any difference.
    What am I missing or doing wrong here? Any help is greatly appreciated. See code below...
    Thanks.
    Environment: Tomcat 5.5.23, MyFaces 1.1.5
    the simplified JSP fragment:
        <h:form id="dynamicFormId" binding="#{dynamicFormBean.dynamicForm}">
            <h:commandButton value="Add Row" action="#{dynamicFormBean.addRow}" immediate="true"/>
        </h:form>the simplified backing bean implementation:
    class DynamicFormBean {
       private HtmlForm dynamicForm;
       // the method called when the button to add components to the form is clicked
       public void addRow() {
           HtmlOutputText outputText = new HtmlOutputText();
           outputText.setId( "someid" ); // this is just for simplicity, the real code creates unique ids ...
           outputText.setValue( "some label" );
           dynamicForm.getChildren().add( outputText );
    }

    Try these small changes:
       public String addRow() {
           HtmlOutputText outputText = new HtmlOutputText();
           outputText.setId( "someid" ); // this is just for simplicity, the real code creates unique ids ...
           outputText.setValue( "some label" );
           dynamicForm.getChildren().add( outputText );
           return "reload";
       }And in your faces-config.xml file, add a navigation rule for the JSP with the dynamic form:
         <navigation-rule>
              <from-view-id>/dynamicForm.jsp</from-view-id>
              <navigation-case>
                   <from-outcome>reload</from-outcome>
                   <to-view-id>/dynamicForm.jsp</to-view-id>
              </navigation-case>
         </navigation-rule>Notice that I added a String return on your action method. What this should do is force JSF to reload the view, and thus the component tree (when coupled with an appropriate navigation case).
    CowKing

  • Question on component cache

    I have built a component that wraps a standard button component. Based on some criteria, it enables/disables the button it wraps.
    In my JSP A.jsp,
    <s:myComp userName="">
    <h:commandButton disabled=false>
    </hx:commandExButton>
    </s:myComp
    In the encodeChildren method of my custom component,
    if( component instanceof HtmlCommandExButton ) {
    if( some condtion) {
    System.out.println(" Is button disabled "+ ((HtmlCommandExButton)component).isDisabled);
    //If button is enabled, disable it.
    ((HtmlCommandExButton)component).setDisabled(true);
    Scenario:
    1) I go to page A. My custom component disables the button by calling setDisabled method
    2) I go to a different page and then come back to page A in the same session
    3) My custom component reads the button's disabled property as true even though the disalbed is set to false in the JSP.
    At step 3, I guess it gets the button component from the component tree cache. I have a few questions.
    1) Is it a good idea to modify the properties of the enclosing components ?
    2) How can I make my component read the real data instead of the cached data for the the enclosing components ?
    3) Is it possible to evaluate the expression bound to disabled property to get the correct value ?

    Hi RaymondDeCampo
    Thanks for the reply. I am not holding the component in the session. It is actually the custom component's encodeChildren method where the child component is passed to it (In my case it is the button). First time when I visit the page, custom component reads the attributes of the child component and modifies them but the modified values will be retained even if I navigate around and come back to the same page.
    HOw can I force JSF to get a fresh instance of the component ?
    I am using IBM JSF1.1

  • Restart Tomcat with every JSP change??

    I hope I'm missing something obvious here...
    Using JWSDP-1.2 (EA4).
    Every time I make a change to the component tree by adding an <h:whatever> tag in my page, JSF breaks when I refresh.
    For example, if I have the code below:
          <h:input_text id="password" valueRef="testBean.password">
               <f:validate_required/>
          </h:input_text>             
          <h:command_button id="submit" label="Submit"
            commandName="submit" />And I insert this line before the <h:command_button>:
    <h:output_errors  for="password"/>  The command button does not render.
    I find that the only way to get the page to render correctly is to go to the Tomcat manager, reload the webapp, and then use another JSP to invalidate my session. Then the page functions correctly. Pretty cumbersome for someone who develops JSPs with the "modify and refresh" method.
    Is this standard behavior that all of you are encountering? Will it continue to be so?

    From what I learned with tryout and error, you need to force JSF to recreate the components tree for it to register modifications.
    The easiest way I found was to load another page with JSF, so I made a link to another page from within the page I was testing.
    Hope this help.
    Patrick

  • Changing form components by selectOneMenu - so easy, but doesn't work

    Hi,
    I have silly problem that makes me crazy: I have a little form and I want to change content of all components dependent on my choice made in selectOneMenu. But it doesn't work like it's supposed to in logical way. For instance I have a selectOneRadio component in which I want to display a proper radio marked dependent on my choice in selectOneMenu. So I am setting Radio's 'rodzaj' bean property (Integer) in the valueChangeListener (idZmWart) of Select element to the chosen value. Bean is updated, but no effect on the page at all, no matter of Select's choice. Am I completely misunderstanding JSF lifecycle (studied many times) or it's just a very stupid mistake?
    Code is below:
    code fragment in jsp page:
    <f:view>
      <h:form>
         <h:selectOneMenu id="wyborId" value="#{Backingbean.id}"
                       valueChangeListener="#{Backingbean.idZmWart}"
                       onchange="submit()">                                  
             <f:selectItems value="#{Backingbean.listaId}" />              
         </h:selectOneMenu>
        <h:selectOneRadio id="wyborRodzaj" value="#{Backingbean.rodzaj}"
                      valueChangeListener="#{Backingbean.rodzajZmWart}"
                      onchange="submit()">
             <f:selectItems value="#{Backingbean.listaRodzaj}"/> 
        </h:selectOneRadio>                              
       <h:commandButton value="button" action="#{Backingbean.button_action}" />                               
    </h:form>
    </f:view>Backingbean code:
    package com.jsf;
    import java.util.ArrayList;
    import javax.faces.context.FacesContext;
    import javax.faces.event.ValueChangeEvent;
    import javax.faces.model.SelectItem;
    public class Backingbean {
       public Backingbean() {
       public String button_action()
          setRodzaj(getId());                
          return "success";
       private Integer id = new Integer(1);
       public Integer getId() {
          return id;
       public void setId(Integer id) {
          this.id = id;
       public void idZmWart(ValueChangeEvent ev) {
          if (ev.getNewValue() != null){
             Integer i = (Integer) ev.getNewValue();
             setRodzaj(i);          
       private ArrayList listaId = new ArrayList();
       public ArrayList getListaId() {     
          ArrayList tmpLista = new ArrayList();
          for (int j=1; j<5; j++) {
             Integer i = new Integer(j);           
             SelectItem si = new SelectItem(i, i.toString());           
             tmpLista.add(si);                    
          listaId = tmpLista;
          return listaId;
       public void setListaId(ArrayList listaId) {
          this.listaId = listaId;
       private Integer rodzaj = new Integer(1);
       public Integer getRodzaj() {
          return rodzaj;
       public void setRodzaj(Integer rodzaj) {
          this.rodzaj = rodzaj;
       private SelectItem[] listaRodzaj = {
          new SelectItem(new Integer(1), "przedmiot"), //value, label
          new SelectItem(new Integer(2), "pracownik"),     
          new SelectItem(new Integer(3), "strona"),     
          new SelectItem(new Integer(4), "menu"),     
       public SelectItem[] getListaRodzaj() {
          return listaRodzaj;     
       public void setListaRodzaj(SelectItem[] listaRodzaj) {
          this.listaRodzaj = listaRodzaj;
       public void rodzajZmWart(ValueChangeEvent ev) {
          if (ev.getNewValue() != null) {
             String sRodzaj = ev.getNewValue().toString();        
    }And fragment of faces-config.xml - in one of the many shapes I've tried
    <managed-bean>
       <managed-bean-name>Backingbean</managed-bean-name>
       <managed-bean-class>com.jsf.Backingbean</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>
       <managed-property>listaId</managed-property>
    </managed-bean>
    <managed-bean>
       <managed-bean-name>listaId</managed-bean-name>
       <managed-bean-class>java.util.ArrayList</managed-bean-class>
       <managed-bean-scope>session</managed-bean-scope>  
    </managed-bean>Thanks for any reply. Regards,
    savage82

    Yeh sorry the points are not linked so you either can do 1 or 2 or 3
    With 3)
    You would have to bind all the components that get updated by your value changed listeners to your backing bean (using the binding attribute)
    And in your value changed listeners you would call the .setValue() on the components whose variable values changed during the value changed code. When your finished you would call the .renderResponse(). The reason this works is that a straight call to .renderResposne() it seems JSF does something funny, it should call the getters() of your variables then use these values and call the .setValue() on your components. But it doesn�t so instead you call the .setValue() yourself. The problem is you have to update every component potentially allot of work
    point 2 is an easy solution
    from my blog
    public void changeMethod(ValueChangeEvent event)
    PhaseId phaseId = event.getPhaseId();
    String oldValue = (String) event.getOldValue();
    String newValue = (String) event.getNewValue();
    if (phaseId.equals(PhaseId.ANY_PHASE))
    event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
    event.queue();
    else if (phaseId.equals(PhaseId.UPDATE_MODEL_VALUES))
    // do you method here
    }what this does the changeMethod will get called twice. First off it gets called when it is meant to during validation phase. So we catch this call in our if statment then we queue the value changed event until the update model phase. So then when the update model phase is called your value changed event will be fired again. Basically this just moves the value changed code after the setters are called. That way any changes you make to your component values in your value change code will not be overwritten by the setters.
    point 1)
    Sorry forgot to add you may need renderResponse() after navigation rule (should test this)
    using the navigation rule well i dont exactly understand why this works. But my educated guess is using a navigation rule forces jsf to recreate the view i.e. the component tree is lost so the values you change in your value changed listeners will be reflected in your components as the components get recreated with the changed variables values.
    So take the above code
    and replace // do you method here
    with whatever your value changed code would be
    This is possibly a bad solution not exactly sure the performance hit you would take on this one i have never noticed any problems with my system but never benched marked it either.

  • Updating/Reloading Message Bundles

    Hi!,
    I'm developing a JSF application which needs its Message Bundles to be updated quite regularly. The only way I've found to reload a message bundle file is to reload the context, which is not only tedious but also potentially hazardous as, under high client loads, sessions might be destroyed and the clients might lose their ongoing transactions.
    Do I have any simpler way of making JSF reload a message bundle whenever it changes? Or at least force JSF to reload a message bundle when I want it to?
    Kind Regards,
    Guido

    Well... I've removed the Duke Dollars as I've found the reply.
    As there is no standard method in ResourceBundle, the non-standard way to do it involves reflection to make the cacheList field accessible, clearing it then make it private again, all of this in the ResourceBundle instance to be reloaded.
    The code to do so is:
    Field field = ResourceBundle.getBundle("resources.framework").getClass().getSuperclass().getDeclaredField("cacheList");
    field.setAccessible(true);
    sun.misc.SoftCache cache = (sun.misc.SoftCache)field.get(null);
    cache.clear();
    field.setAccessible(false);Obviously, where "resources.framework" is your resource bundle name.
    I think that the reloading of a whole set of internationalized bundles would involve getting the faces context, retrieving all the installed locales, then acquiring the bundles one by one and applying this method.
    Cheers!
    Guido
    Buenos Aires - Argentina

  • MyFaces TabbedPane

    I have 2 tabs, one tab as <h:inputText> and the other tab has <h:dataTable> . The Datatable also has TextBoxes .
    My question is when I move from 2nd tab after modifing values of textbox in datatable to 1st tab and come back to 2nd tab, My modified values are going away.
    Anybody has any ideas.
    Thanks
    John

    Hello BalusC,
    ich have a similar problem.
    when the user want to chance the tab, i want to force JSF to update my managed Bean. You said, that you used the odc:bfPanel Attribut onenter to attach JS to a backing bean. Can you give me a little example?
    thx a lot!
    Andre

  • Force click event in a jsf page

    Hello, i need make automatic click event to login in a system.
    i get the user and password by session, but i don't want the user make more login.
    Example:
    My main page(login A)------> ( login B)Other applications
    I need automatic login on B using user/password from login A.
    Thanks

    ok if i understand your quest you want to not have a user login on the same page? so log in for one application log in for both?
    what you could do is setup a viewHandler and in the createView() check if the user is loged in i.e pull username and password from session
    if the user is loged in then create the View for you first page in B. if the user is not loged in create the view for the login B page
    thats the best way to do this
    or a hack way is to have javascript that clicks the login button on login B
    :)

  • Problem in JSF with Swing in a web application

    hi
    i am using jsf for my online projects.my problem is that when i use Swing concept ,the server is closed automatically when i click the swing dialog option 'OK', how can i protect server being closed automatically when user click the the options of Swing dialog box.it is so tedious because my application is going to integrate
    with online server?
    my swing java file is
    * FileExistsDialog.java
    package com.obs.ftw.util.alert;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.Rectangle2D;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    * FileExistsDialog: A JOptionPane-like dialog that displays the message
    * that a file exists.
    public class FileExistsDialog extends JDialog {
    * The component that gets the focus when the window is first opened
    private Component initialFocusOwner = null;
    * Command string for replace action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_REPLACE = "OK"/*NOI18N*/;
    * Command string for a cancel action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_CANCEL = "CANCEL"/*NOI18N*/;
    // Components we need to access after initialization
    private JButton replaceButton = null;
    private JButton cancelButton = null;
    public FileExistsDialog(){
         System.out.println("INSIDE THE FILE EXIST DIALOG");
         JFrame frame = new JFrame() {
         public Dimension getPreferredSize() {
         return new Dimension(200,100);
         frame.setTitle("Debugging frame");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(false);
    FileExistsDialog dialog = new FileExistsDialog(frame, true);
         dialog.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
         System.exit(0);
         public void windowClosed(WindowEvent event) {
         System.exit(0);
         dialog.pack();
         dialog.setVisible(true);
    * Creates a new FileExistsDialog
    * @param parent parent frame
    * @param modal modal flag
    public FileExistsDialog(Frame parent,boolean modal) {
    super(parent, modal);
         //initResources();
         System.out.println("INSIDE THE FILE EXIST DIALOG CONSTRUCTOR");
    initComponents();
    pack();
    * Determines the locale, loads resources
    /* public void initResources() {
         Locale locale = Locale.getDefault();
    resources = ResourceBundle.getBundle(
              "samples.resources.bundles.FileExistsDialogResources", locale);
    imagePath = resources.getString("images.path");
    }*/ // initResources()
    * Sets all of the buttons to be the same size. This is done
    * dynamically after the buttons are created, so that the layout
    * automatically adjusts to the locale-specific strings.
    private void equalizeButtonSizes() {
         System.out.println("INSIDE THE equalizeButtonSizes()");
    String[] labels = new String[] {
    replaceButton.getText(),
         cancelButton.getText()
         // Get the largest width and height
         Dimension maxSize= new Dimension(0,0);
         Rectangle2D textBounds = null;
         Dimension textSize = null;
    FontMetrics metrics =
              replaceButton.getFontMetrics(replaceButton.getFont());
         Graphics g = getGraphics();
         for (int i = 0; i < labels.length; ++i) {
         textBounds = metrics.getStringBounds(labels, g);
         maxSize.width =
         Math.max(maxSize.width, (int)textBounds.getWidth());
         maxSize.height =
         Math.max(maxSize.height, (int)textBounds.getHeight());
    Insets insets =
         replaceButton.getBorder().getBorderInsets(replaceButton);
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;
    // reset preferred and maximum size since BoxLayout takes both
         // into account
    replaceButton.setPreferredSize((Dimension)maxSize.clone());
    cancelButton.setPreferredSize((Dimension)maxSize.clone());
    replaceButton.setMaximumSize((Dimension)maxSize.clone());
    cancelButton.setMaximumSize((Dimension)maxSize.clone());
    } // equalizeButtonSizes()
    * This method is called from within the constructor to
    * initialize the dialog.
    private void initComponents() {
         System.out.println("INSIDE THE initComponents()");
         // Configure the window, itself
    Container contents = getContentPane();
    contents.setLayout(new GridBagLayout ());
    GridBagConstraints constraints = null;
    setTitle("Waring");
         // accessibility - all applets, frames, and dialogs should
         // have descriptions
         this.getAccessibleContext().setAccessibleDescription("Descriptions");
         addWindowListener(new WindowAdapter() {
         public void windowOpened(WindowEvent event) {
              // For some reason the window opens with no focus owner,
              // so we need to force the issue
         if (initialFocusOwner != null) {
              initialFocusOwner.requestFocus();
              // Only do this the 1st time the window is opened
              initialFocusOwner = null;
         public void windowClosing(WindowEvent event) {
         System.out.println("INSIDE THE windowClosing");     
         // Treat it like a cancel
              windowAction(CMD_CANCEL);
         // image
    JLabel imageLabel = new JLabel();
    imageLabel.setIcon(
    new ImageIcon("/images/degraded_large.gif"));
    // accessibility - set name so that low vision users get a description
    imageLabel.getAccessibleContext().setAccessibleName("OK");
    constraints = new GridBagConstraints ();
    constraints.gridheight = 2;
    constraints.insets = new Insets(12, 33, 0, 0);
    constraints.anchor = GridBagConstraints.NORTHEAST;
    contents.add(imageLabel, constraints);
    // header
    JLabel headerLabel = new JLabel ();
    headerLabel.setText("SAMPLE");
    headerLabel.setForeground(
         new Color(MetalLookAndFeel.getBlack().getRGB()));
    constraints = new GridBagConstraints ();
    constraints.insets = new Insets(12, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(headerLabel, constraints);
         // Actual text of the message
         JTextArea contentTextArea = new JTextArea();
    contentTextArea.setEditable(false);
    contentTextArea.setText("SAMPLE");
    contentTextArea.setBackground(
              new Color(MetalLookAndFeel.getControl().getRGB()));
    // accessibility -- every component that can have the
         // keyboard focus must have a name. This text area has no
         // label, so the name must be set explicitly (if it had a
         // label, the name would be pulled from the label).
    contentTextArea.getAccessibleContext().setAccessibleName(
              "CONTENTNAME");
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(contentTextArea, constraints);
         // Buttons
         JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout (new BoxLayout(buttonPanel, 0));
         replaceButton = new JButton();
         replaceButton.setActionCommand(CMD_REPLACE);
    replaceButton.setText("OK");
    replaceButton.setToolTipText("TO OK");
         replaceButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(replaceButton);
    // spacing
    buttonPanel.add(Box.createRigidArea(new Dimension(5,0)));
         cancelButton = new JButton();
         cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.setText("CANCEL");
    cancelButton.setNextFocusableComponent(replaceButton);
         cancelButton.setToolTipText("TO CANCEL");
         cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(cancelButton);
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(12, 12, 11, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(buttonPanel, constraints);
         // Equalize the sizes of all the buttons
         equalizeButtonSizes();
         // For some reason, the dialog appears with no input focus.
         // We added a window listener above to force the issue
         initialFocusOwner = replaceButton;
    } // initComponents()
    * The user has selected an option. Here we close and dispose the dialog.
    * If actionCommand is an ActionEvent, getCommandString() is called,
    * otherwise toString() is used to get the action command.
    * @param actionCommand may be null
    private void windowAction(Object actionCommand) {
         System.out.println("INSIDE THE WINDOW ACTION");
         String cmd = null;
    if (actionCommand != null) {
         if (actionCommand instanceof ActionEvent) {
         cmd = ((ActionEvent)actionCommand).getActionCommand();
         } else {
         cmd = actionCommand.toString();
         if (cmd == null) {
         // do nothing
         } else if (cmd.equals(CMD_REPLACE)) {
         System.out.println("your replace code here...");
         } else if (cmd.equals(CMD_CANCEL)) {
         System.out.println("your cancel code here...");
         setVisible(false);
         dispose();
    } // windowAction()
    * This main() is provided for debugging purposes, to display a
    * sample dialog.
    // main()
    } // class FileExistsDialog
    and calling java function is
    public String fileDialog(){
         return "Success";
    public void processFile(ActionEvent event){
         System.out.println("INSIDE THE FILE DIALOG");
         FileExistsDialog file     = new FileExistsDialog();
         System.out.println("SUCCESS");
    called from
         <h:commandButton action="#{userLogin.fileDialog}" actionListener="#{userLogin.processFile}"></h:commandButton>
    pls help me as soon
    advance thanks
    rgds
    oasisdeserts

    Swing is GUI library for use in desktop applications.
    JSF is a web application framework which runs on an application server and is accessed by clients via web browsers.
    To fully understand what you have done, try accessing your application from a different machine than the server.
    To answer your question, don't invoke System.exit() if you would like the process to continue. But that is the least of your problems.

  • Is there a way to force the charset to utf-8 with the IIS plug-in?

    We're using AJAX. The initial request for the HTML has charset=utf-8 set on the HTTP header as seen in this Live HTTP Headers capture:
    http://plper.mysite.com/mysupport/index.jsf
    GET /mysupport/index.jsf HTTP/1.1
    Host: plper.mysite.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Cookie: mysiteSiteUrl=http://www.mysite.com; Amysession=aHR0cDovL3BscGVyLmVtYy5jb206ODAv; JSESSIONID=FN3WLTNJFJCfYhHHVrwKvLHF2gGdnnTb11DrCyZqR9YbGhcG28lK!-1728721171; mysession=AAAAAgABAFBy5LRMDmjSRCN%2FByvfquVwFeKCpmES4x9lReRava35fxKfwcbJimb3YyPhEd0vBq7ZxgJVecL475TFZwQuSphLOwRWAQw2t7PEW%2BrxsfxgnQ%3D%3D
    HTTP/1.x 200 OK
    Date: Tue, 10 Jun 2008 18:53:01 GMT
    Server: Microsoft-IIS/6.0
    Cache-Control: no-store,no-cache,must-revalidate, no-cache="set-cookie"
    Pragma: No-cache
    Transfer-Encoding: chunked
    Content-Type: text/html;charset=UTF-8
    Expires: Thu, 01 Jan 1970 00:00:00 GMT
    Set-Cookie: JSESSIONID=09VTLTNWT07LlqnK22jTWwM8y5L9v1rmPf9CTW5TnGGKBvWvjJpP!-1728721171; path=/
    Content-Language: en-US
    X-Powered-By: Servlet/2.5 JSP/2.1
    Subsequent requests do not:
    http://plper.mysite.com/mysupport/index.jsf
    POST /mysupport/index.jsf HTTP/1.1
    Host: plper.mysite.com
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14
    Accept: application/x-backbase+xml,application/xhtml+xml,application/xml,text/xml,application/x-www-form-urlencoded,*/*;q=0.5
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Referer: http://plper.mysite.com/mysupport/index.jsf
    Content-Length: 122
    Cookie: mysiteSiteUrl=http://www.mysite.com; Amysession=aHR0cDovL3BscGVyLmVtYy5jb206ODAv; JSESSIONID=09VTLTNWT07LlqnK22jTWwM8y5L9v1rmPf9CTW5TnGGKBvWvjJpP!-1728721171; mysession=AAAAAgABAFBRtE5lAyr85YM0aIap%2Bekf1Qu8FoA6BNh4JVl1JgvDNDQgYrQm5m9W%2FQa4HLK767CtXV5c%2FhtXchbug9%2BE1zoCmqSBqqYmqXE9VG1lXi%2F%2Brg%3D%3D
    Pragma: no-cache
    Cache-Control: no-cache
    BackbaseClientDelta=%5Bevt%3DsrQuery%3AsiteList%7Cevent%7Csubmit%5D%5Bvalue%3DsrQuery%3AsiteList%7Cmultivalue%7C3971957%5D
    HTTP/1.x 200 OK
    Date: Tue, 10 Jun 2008 18:58:17 GMT
    Server: Microsoft-IIS/6.0
    Content-Length: 1720
    Content-Type: text/xml
    X-Powered-By: Servlet/2.5 JSP/2.1
    Is there a way to force requests going through the proxy plug-in to get a charset=utf-8 set in the HTTP header for all requests?
    Thanks!
    Edited by f2racer at 06/10/2008 12:01 PM

    If for some reason you have failed to maintain a backup copy of your computer ( not good), then transfer purchases form your ipod.
    Without syncing, click File>Transfer Purchases

  • Authentication in JSF 2.0

    I could use some advise... I've been trying to implement authentication in a JSF 2.0 web application and I've not been completely successful. I'm using NetBeans 6.8 and GlassFish v3. Here is what I would like:
    1) Use container managed security with a JDBC realm. Users who register via the web app will end up as users in the table that is used to authenticate access to the web app
    2) I want to use role-base authorization that I can specify in my web.xml file as [described in the JEE 6 tutorial.|http://java.sun.com/javaee/6/docs/tutorial/doc/bnbxj.html#bnbxu]. Thus, I'd like to secure JSF pages as well as managed bean actions.
    3) My web app uses EJB's that are secured using the [EJB annotations as described in the JEE 6 tutorial|http://java.sun.com/javaee/6/docs/tutorial/doc/bnbyl.html#gjgcq]. My understanding is that the credentials from the web app are propagated to the EJB's, so I should not need to do anything, other than catch exceptions whenever the EJB is being accessed by an unauthorized role.
    4) Ideally, I'd like to use a JSF form to request username/password from a user. I know the JSF form cannot directly post the information to the container's security mechanism (i.e. j_security_check action). While I've found some ways to do it, none are really satisfactory, so I've had to just use a plain HTML form.
    5) I could do it [authentication programmatically as explained in the JEE 6 tutorial|http://java.sun.com/javaee/6/docs/tutorial/doc/gjiie.html]. Unfortunately, the tutorial shows how to do this from a Servlet and not from JSF. In particular, I could invoke the HttpServletRequest#login method, but its result does not enter a session and thus I cannot continue to use container managed authorization past the request. If I use HttpServletRequest#authenticate, then this will force the container to present the login form I specify in web.xml and the credentials will be in the session.
    6) FYI, I've tried to implement an authentication a Filter but the URL requests that come from a JSF 2.0 app just do not correspond to what I'm looking for in the filter. That is, if I have a directory named secured where I keep JSF pages to be accessed only by authenticated users, I set up a Filter to look for these requests and it does not behave as expected (or at least the way it behaves when I use it with JSP)
    I hope someone here can help me find the resources so I can implement this. I've Googled many times and most of what I'm finding is incomplete. I'd greatly appreciate anyone's help and guidance in this. FYI... some students are counting on me to deliver a solution to this! I did not think it would be difficult, but it has turned out to be that way.
    Thanks for reading this far!
    Alvaro

    Hello Ed. I have your JSF 2.0 book now. I download and tried the authentication example that you have on chapter 14. Unfortunately, authorization is not working as I would expect it. Here are the specifics:
    1) I'm running it on GlassFish v3
    2) According to the web.xml, you create two security constraints. One on /trainer/*** requests to be accessed only by users with role of trainer. Another on the /user/*** requests to be accessed only by users with role of user
    3) Whenever I try this app, I can access that pages without ever being authenticated (i.e. without logging in). I can access them by entering the URL's, say: http://localhost:8080/formBasedLogin/faces/user/userPage.xhtml
    This is the problem I've been having whenever I try to do authorization. For some reason, either the URL is not matching the pattern specified or it gets rewritten by JSF 2.0 in some way?
    Update: I'll leave the above comments, but I was able to get your example working by changing the URL patterns to: /faces/user/*** and /faces/trainer/*** Is this an error in the sample code or should the pattern you provide still work?
    Update 2: It seems that I've now figured out that there is a difference on whether I use an outputLink or a commandLink. I need to read more about this. In any case, the URL patterns do match requests that are specified as an outputLink, but not when they are specified by a commandLink -- in this case, JSF uses JavaScript to make the request to some resource which does not match the pattern. It looks like I was just using commandLink before whereas I should have been using outputLink.

Maybe you are looking for

  • Creation of production order while mrp run

    hi ppgurus can any body explain how to create a production order by mrp run ie sysytem should create the production order directly while mrp run not PLANNED ORDERS what settings i need to do for  this plz explain urgent requirement regards sasikanth

  • OFTP_TCP Receiver channel error

    Hello All, To an exisitng sceanrio of EDI Sales Invoices i have added new party. For this i have taken as refrence an exisiting party in the scenario. While testing newly configured party interface I am getting the errors in receiver channel as below

  • Adding a Z field in Standard Database view

    Hi ALL My requirement is to add a z field in a Standard Database View . Please advice how do i go ahead . Urgent help will be appreciated . Thanks Shweta

  • Creating Agreements between 2 remote trading partners???

    Hi All, We are planning to use B2B as HUB and via Self service API we are able to create the agreement between 2 remote TPs. When I enqueue the message to IPN_IN_QUEUE with FROM_PARTY as TP1 and TO_PARTY as TP2, will this work... any limitations or a

  • Microsoft Teredo Tunneling Adapter and Microsoft Teredo Tunneling Adapter #2

    I have a Dell XPS STUDIO 7100, with MS Windows 7 Home Premium for the past several days my system is running poorly. In device manager there's yellow hi-lite for MS Teredo Tunneling Adapter and Adapter #2.  the postings I've seen are not current.  Wh