JSF outputLink

Hi all,
I have been trying to link an external URL from within the portlet. We are using JSF portlet framework and Im using <hx:outputLinkEx/> tag to render the URL. Unfortunately the URL is being prepended with some stuff. For example, I m having a backing bean and a property named link which is binded to the output link tag. The following output resulted when I tried to render the URL.
The link property is a String
<h:outputLink id="link2" value="#{myBean.link}">
<h:outputText id="outputText4" value="#{myBean.link}"></h:outputText>
</h:outputLink>
Output:
<TD>
<a id="viewPC_7_0_12F_:table1:0:link2" href="http://localhost:9081/wps/PA_1_0_IR/http://yahoo.com">
<span id="viewPC_7_0_12F_:table1:0:outputText4">http://yahoo.com</span>
</a>
</TD>
Has anyone encountered this problem before or are there any workarounds for this problem? I also tried to use <h:outputLink/> but invain.
Help would be greatly appreciated.
Thank u
-Sri

any clues or ideas

Similar Messages

  • JSF - outputLink attribute

    Hi all,
    I have one JSF page that contains some outputLink elements. Each of the elements points to page that should get parameter passed by the previous JSF page.
    I have read an article how to pass that parameters by using the URL ( http://localhost:8080/MyProg?MyParam=sample) but I do not want use method.
    I have tried to create an attribute and pass it to the bean but without success.
    Can you tell me how I can pass parameter from outputLink element to the next page?
    Thanks in advance.

    Use h:commandLink. It will create a POST request instead of GET request (which you don't want to use).

  • JSF 2.0 commandLink link, outputLink, etc

    I have a paragraph like below
    Nowis the time for all good men to come to the aid of their country. If
    they don'e it could be the end of us
    I want to put a command link in this paragraph for say "good men" so it looks like this
    Nowis the time for all good men to come to the aid of their country. If
    they don'e it could be the end of us
    When I use the <h:commandLink action="#{mybean.clickLink}" value="good men"/>, the link works just fine, but renders like this on the page
    Nowis the time for all
    good men
    to come to the aid of their country. If they don'e it could be the end of us
    Is there anyway to keep the <tr></tr> from rendering around the link when it's turned into HTML? Is there another tag that will still let me use action="#{mybean.clickLink}"???? This link MUST go back through the server.
    Thanks,
    Doug

    I found the problem and a solution :-) The missing piece of the puzzle was the id attribute for the form tag. After some debugging of the JSF JavaScript I found the solution.
    The JavaScript function response(request, context) is invoked to handle the server response. Inside this function the doUpdate(element, context) is invoked.
    The doUpdate() function is doing the modification of the DOM. The function doUpdate() is two times invoked for a response. The first time the html elements are updated.
    The second time the view state hidden field is updated or created but only under the following condition:
    Comment in the JavaScript source code of the jsf.js
    //Now set the view state from the server into the DOM
    //but only for the form that submitted the request.If the forms of the both side haven't the same id the form can't be found on the second page.
    In the following way it is working:
    page1.xhtml
    <h:form id="myform">
            <h:commandLink value="Go to page 2" action="page2">
                <f:ajax render="@all" execute="@all"/>
            </h:commandLink>
    </h:form>
    .....page2.xhtml
    <h:form id="myform">
                <h:commandLink value="Go to page 1" action="page1">
                    <f:ajax render="@all" execute="@all"/>
                </h:commandLink>
    </h:form>So always set an explicit id for each JSF tag.

  • Open File from Filesystem with OutputLink

    I have implemented an UploadForm with JSF. With this form a File is uploaded to my filesystem and some data (link to filename, filename itself and so on) are written to the Database.
    No I display these data from the database in a datatable and I want to implement a link, that the user can open the file from the filesystem. I have tried a outputlink with something like that:
    <h:outputLink value="file:C:\Entwicklung\IDE\eclipse\readme.txt" target="_blank">
                   <f:verbatim>
                        Test
                   </f:verbatim>
    </h:outputLink>
    I'm not sure if the file: Command is the right...
    The problem is, that nothing happens. When I try to save the file, pressing the right button and choose "Save as..." the file is correctly saved.
    How can I implement a link to open a file from the filesystem?
    Regards,
    Andy

    No the file won't be a html file..
    I will be some kind of pdf or doc?
    So how to launch them? Do I need an Outputstream?
    Has anyone experiences with that?Any file could go as an href value.
    Issue is not file type, but a proper URI that the server could resolve.

  • Can we  have a href tags in jsf page

    hi all,
    I tried inserting a link in jsf page using <a href> tag but when I click it, it is appending the link to contextroot.
    For Example:
    <f:verbatim>
    click here
    </f:verbatim>
    and when I click on it, I see http://www.google.com is appended to my application url after context root like
    http://localhost:9080/Ma/view/India/http://www.google.com
    and I get 404 error. how do I do it without having my application url.
    Thanks
    Ma
    Edited by: niki007 on Jan 12, 2009 4:32 PM

    This problem can occur if you didn't specify any protocol (http:// or https:// or others) in the link. But your example looks fine. I think that you modified the real code to this example, without being aware that you solved the problem yourself.
    At any way, you can also just use h:outputLink to render <a> elements.

  • 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.

  • Hyperlink in JSF

    How can we create hyperlink in JSF, in <h:commandLink there is no attribute for url ?

    <h:outputLink>

  • JSF navigation rules sent me to different page, with same URL

    Hello everybody,
    Have a newbie question on JSF, if anyone can help me. I am using JSF for a web application, and i have a small problem.
    If i define a navigation rule, from one page to another, and i am having a button that should send me to another page,
    the browser URL remains the same, although the page content IS correctly changed.
    Thanks,
    Andrei

    You're welcome.
    Though I should have added that the advantage of the redirect after a POST request is that refreshing the request or navigating back and forward by browser history doesn't cause a re-submit of the POST request anymore. This way you avoid duplication of submitted data. This is called POST-redirect-GET pattern. Refreshing the request after a redirect (which is always a GET request) would only cause the redirect being refreshed, not the initiating POST request.
    The disadvantage of a forward is less or more obvious: the URL remains the same and it is not really good for the user experience. If one copypasted the URL in a new window (a new GET request), one wouldn't see the forwarded page, but the originating page. That's why I would recommend to avoid navigation cases and just use the same page to postback the POST request to. For normal page-to-page navigation within a website, I would recommend just using outputlinks and not commandlinks with navigation cases. It's all better for the user experience.

  • Problem with Non JSF Request to JSF Page

    Hi All,
    I am working on dynamic controls generation based on the request come from non jsf page
    For the first request, pageworks perfectly. but when we go for second request, it is not rendering and I am getting same old page.
    What I have identified is if I have 2 pages as JSF, application is not giving any problem.
    For this I have written small test application contains both JSF pages only.
    page1 contains 3 submit buttons.
    When submit buttons are clicked based on the request, I get, am able to see the dynamic controls.
    SO there is no problem with JSF PAGE to JSF Page Communication
    Now I have done some changes in First JSF page. Instead of submitting directly I am submitting the page through JavaScript which is nonb JSF request. There I am facing the problem and based on requested qaction I am not able to see correct rendered page based on the requested action.
    Any Idea why it is giving problem for non JSF requests??
    Thanks
    Sudhakar

    For Your Convenience in understanding the problem
    I am pasting entire test code
    Page 1 -- (here page2 is Page1 and Page1 is page2 - some naming convention errors :) )
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page2 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page2.form1}" id="form1">
    <!-- Non JSF REquests -->
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=1'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=2'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=3'; document.forms['form1'].submit(); return false;"/>
    <!-- this  is JSF request -->
                        <!--
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" />-->
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>Page1 Bean
    * Page2.java
    * Created on June 25, 2005, 11:08 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class Page2 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlCommandButton button2 = new HtmlCommandButton();
        public HtmlCommandButton getButton2() {
            return button2;
        public void setButton2(HtmlCommandButton hcb) {
            this.button2 = hcb;
        private HtmlCommandButton button3 = new HtmlCommandButton();
        public HtmlCommandButton getButton3() {
            return button3;
        public void setButton3(HtmlCommandButton hcb) {
            this.button3 = hcb;
        // </editor-fold>
        public Page2() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
            } catch (Exception e) {
                log("Page2 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        public String button1_action()  throws Exception{
            // TODO Following code was replaced by static navigation
           getSessionBean1().setId(1);       
          /* ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case1";
        public String button2_action()  throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(2);
          /*  ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case2";
        public String button3_action() throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(3);
            /*    ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
            return null;*/
            return "case3";
    }page 2
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page1 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page1.form1}" id="form1">
                        <h:panelGrid binding="#{Page1.gridPanel1}" id="gridPanel1" style="left: 96px; top: 48px; position: absolute"/>
                        <f:selectItems binding="#{Page1.radioButtonList1SelectItems1}" id="radioButtonList1SelectItems1"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1"
                            style="left: 384px; top: 120px; position: absolute" value="Submit"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" style="left: 384px; top: 72px; position: absolute" value="Submit"/>
                        <h:outputLink binding="#{Page1.hyperlink1}" id="hyperlink1" style="left: 480px; top: 216px; position: absolute" value="http://www.sun.com/jscreator">
                            <h:outputText binding="#{Page1.hyperlink1Text}" id="hyperlink1Text" value="Hyperlink"/>
                        </h:outputLink>
                        <h:commandLink binding="#{Page1.linkAction1}" id="linkAction1" style="left: 456px; top: 264px; position: absolute">
                            <h:outputText binding="#{Page1.linkAction1Text}" id="linkAction1Text" value="Link Action"/>
                        </h:commandLink>
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>page2 bean
    * Page1.java
    * Created on June 25, 2005, 10:52 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import com.sun.jsfcl.data.DefaultSelectItemsArray;
    import java.util.Vector;
    import javax.faces.component.UIComponent;
    import javax.faces.component.UISelectItems;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.model.SelectItem;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Page1 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
        public HtmlPanelGrid getGridPanel1() {
            return gridPanel1;
        public void setGridPanel1(HtmlPanelGrid hpg) {
            this.gridPanel1 = hpg;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlOutputLink hyperlink1 = new HtmlOutputLink();
        public HtmlOutputLink getHyperlink1() {
            return hyperlink1;
        public void setHyperlink1(HtmlOutputLink hol) {
            this.hyperlink1 = hol;
        private HtmlOutputText hyperlink1Text = new HtmlOutputText();
        public HtmlOutputText getHyperlink1Text() {
            return hyperlink1Text;
        public void setHyperlink1Text(HtmlOutputText hot) {
            this.hyperlink1Text = hot;
        private HtmlCommandLink linkAction1 = new HtmlCommandLink();
        public HtmlCommandLink getLinkAction1() {
            return linkAction1;
        public void setLinkAction1(HtmlCommandLink hcl) {
            this.linkAction1 = hcl;
        private HtmlOutputText linkAction1Text = new HtmlOutputText();
        public HtmlOutputText getLinkAction1Text() {
            return linkAction1Text;
        public void setLinkAction1Text(HtmlOutputText hot) {
            this.linkAction1Text = hot;
        // </editor-fold>
        public Page1() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
                ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
                HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
                HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
                String id=req.getParameter("id");
                if(id!=null)
                    getSessionBean1().setId(Integer.parseInt(id));
                if (getSessionBean1().getId()==1) {
                    addTextBox();
                else if (getSessionBean1().getId()==2) {
                    addCheckBox();
                    addRadio();
                else if (getSessionBean1().getId()==3) {
                    addRadio();
                   // addCheckBox();
            } catch (Exception e) {
                log("Page1 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        private void addRadio() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc2");
            HtmlSelectOneRadio checkBox = new HtmlSelectOneRadio();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a3");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addCheckBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc1");
            HtmlSelectManyCheckbox checkBox = new HtmlSelectManyCheckbox();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a2");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addTextBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Description for Control Text Box");
            outputText.setId("somedesc");
            HtmlInputText textField = new HtmlInputText();
            //  textField.setId("textField_"+control.getId());
            textField.setId("a1");
            HtmlOutputText outputText1 = new HtmlOutputText();
            hyperlink1Text.setValue(" ");
            hyperlink1Text.setStyleClass("bodyText");
            textField.setStyleClass("frmObjects");
            gridPanel.setColumns(3);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(hyperlink1Text);
            gridPanel.getChildren().add(textField);
            parent.getChildren().add(gridPanel);
        private DefaultSelectItemsArray array = new DefaultSelectItemsArray();
        public DefaultSelectItemsArray getArray() {
            return array;
        public void setArray(DefaultSelectItemsArray dsia) {
            this.array = dsia;
        private Vector vectDefaultSelectItemsArray = new Vector();
        private DefaultSelectItemsArray[] arrays = new DefaultSelectItemsArray[10];
        public DefaultSelectItemsArray[] getArrays() {
            return arrays;
        public void setArrays(DefaultSelectItemsArray[]dsia) {
            this.arrays = dsia;
        private UISelectItems radioButtonList1SelectItems1 = new UISelectItems();
        public UISelectItems getRadioButtonList1SelectItems1() {
            return radioButtonList1SelectItems1;
        public void setRadioButtonList1SelectItems1(UISelectItems uisi) {
            this.radioButtonList1SelectItems1 = uisi;
        private ValueBinding getValueBinding(String expression) {
            return     FacesContext.getCurrentInstance().getApplication().createValueBinding(expression);
        public String button1_action() {
            // TODO Replace with your code
            return "case1";
    }my navigation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <navigation-rule>
            <from-view-id>/Page2.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case2</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case3</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
        <navigation-rule>
            <from-view-id>/Page1.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page2.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>my managed beans xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <managed-bean>
            <managed-bean-name>Page1</managed-bean-name>
            <managed-bean-class>webapplication8.Page1</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>SessionBean1</managed-bean-name>
            <managed-bean-class>webapplication8.SessionBean1</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>ApplicationBean1</managed-bean-name>
            <managed-bean-class>webapplication8.ApplicationBean1</managed-bean-class>
            <managed-bean-scope>application</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>Page2</managed-bean-name>
            <managed-bean-class>webapplication8.Page2</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
    </faces-config>

  • Html outputlink  in datatble

    Hi, in JSF,in a datatable i am using <h:outputLink> for a column..
    and i am using some events for security purpose..
    For example
    <h:commandButton id="btn4grpnam" value="Group Name"
         action="masterfaqsublist" event="faq.addgroup"
         styleClass="submitBtn"/>
    if user have access to next page where this particular command button leads to,the command button will be displayed..or else button won't get displayed..
    the same i tried to use for <h:outputLink> (if user have acces label will be displayed with hyperlink or else simply label will get displayed)
    <h:outputLink id="faq_html_id" event="faq.update"
         value="masterfaqadd.jsp">
    but it is not working... is event attribute does not support for outputlink????
    and if inplace of <h:outputlink> if i use <h:commandlink> its working
    with event but the problem is <h:commandlink is not supporting actions.
    can anybody suggest alternate???????
    thanks in advance,
    saranya

    Use the rendered attribute.
    But: "h:commandlink is not supporting actions". It supports.
    What is the problem? <h:commandLink action="masterfaqadd.jsp"> should work.

  • Help with Anchor in JSF

    <p align="center">  <b>
            For details click
            <a href="#error">
             here
            </a>
          </b></font></p>
    <a name="error"> </a>
    <a href="#top">Top of Page <font size="2"> &uArr;</font></a>Can any one tell me the equivalent JSF syntax for the above anchors

    Make use of the fact that the element ID's in the DOM tree are also useable as anchors.<h:someComponent id="someId" />
    <h:outputLink value="#someId">link</h:outputLink>Take care with woodstocked ID's which may occur in forms, datatables and subviews.

  • How to render outputlink as an area tag rather than an a tag

    Hi all,
    As stated in JSF document, both shape and coords are valid properties in outputlink. So, I have tried following
    <map name="monkey">
    <h:outputLink shape="rect" coords="0,0,30,30" value="http://yahoo.com"/>
    </map>
    however. that is rendered as &lt;a href="http://yahoo.com" coords="0,0,30,30" shape="rect">&lt;/a>, what I really want is
    &lt;area href="http://yahoo.com" coords="0,0,30,30" shape="rect">&lt;/area> ...
    I mean if outputlink can only be render an a tag, but not an area tag, I do not see why it will support shape and coords propeties ...
    Any help here ...
    Thanks a million
    Edited by: EJP on 5/09/2011 10:50: fixed your meta-HTML

    886619 wrote:
    I know that coords and shape are defined in w3c standard, my questions are
    1) what jsf component can be rendered as area tag for html frontend?None that I am aware of. You could write your own. Or, if an existing component is appropriate, you could write an alternative renderer for the component.
    2) "The position and shape of the hot spot on the screen (for use in client-side image maps)." That is the sentence for JSF document, what you think about for use in client-side image map mean? I donot see why render as <a> tag for client-side image map will be an acceptable solution ...I don't think this has anything to do with JSF at this point; JSF simply passes these values through to the rendered HTML. You have to understand how to use HTML to make proper use of these attributes.

  • JSF 2.0 - insert additional content into h:selectOneRadio

    Hello,
    I am trying to convert current pages into JSF and I have difficulties with the following code:
    <div id=set>
      <label>
          <input type="radio" name="inputData" value="default" />
          Default
      </label>
      (<a href="sample.xml">Download 13 kB</a>)
      <br />
      <label>
          <input type="radio" name="inputData" value="custom" checked/>
          Custom
      </label>
        <input id="file" type="file" name="file" size="32"/>
    </div>If I use this JSF 2.0 'alternative'
    <div id=set>
      <h:selectOneRadio id="dataSource" value="#{paramsBean.dataSource}" >
          <f:selectItem itemValue="1" itemLabel="#{i18n.dataSourceDefault}"/>
          <h:outputLink target="sample.xml" title="#{i18n.inputDataDownload} 13 kB"/>
          <br />
          <f:selectItem itemValue="0" itemLabel="#{i18n.dataSourceCustom}"/>
            <input id="file" type="file" name="file" size="32"/>
      </h:selectOneRadio>
    </div>but outputLink is ignored at all while the input file control is placed before radio buttons...
    Is something like this possible or should I use any workaround? I have no idea how to solve this.
    Regards,
    Jan

    Thanks for your hint, but if I use the following code:
    <h:dataTable>
        <h:column>
            <h:selectOneRadio id="dataSource" value="#{paramsBean.dataSource}" >
                <f:selectItem itemValue="1" itemLabel="#{i18n.dataSourceDefault}"/>
                <f:selectItem itemValue="0" itemLabel="#{i18n.dataSourceCustom}"/>
            </h:selectOneRadio>
        </h:column>
        <h:column>
            <h:outputLink value="sample.xml">#{i18n.inputDataDownload} 13 kB</h:outputLink>
            <input id="file" type="file" name="file" size="32"/>
        </h:column>
    </h:dataTable>No output is generated:
    <table>
      <tbody>
        <tr><td></td></tr>
      </tbody>
    </table>I've tried panelGrid instead:
    <h:selectOneRadio id="dataSource" value="#{paramsBean.dataSource}" >
        <h:panelGrid columns="2">
            <f:selectItem itemValue="1" itemLabel="#{i18n.dataSourceDefault}"/>
            <h:outputLink value="sample.xml">#{i18n.inputDataDownload} 13 kB</h:outputLink>
            <f:selectItem itemValue="0" itemLabel="#{i18n.dataSourceCustom}"/>
            <input id="file" type="file" name="file" size="32"/>
        </h:panelGrid>
    </h:selectOneRadio>but although it produces something, it is not complete (notice also an extra table below):
    <table>
      <tbody>
        <tr><td></td><td><a href="sample.xml">download 13 kB</a></td></tr>
        <tr><td></td><td><input id="file" type="file" name="file" size="32" /></td></tr>
      </tbody>
    </table>
    <table id="j_idt28:dataSource">
         <tr></tr>
    </table>I've tried many combinations - it produces either incomplete outputs or improper nested tables in cells... No attempt has been successful yet.
    I am quite annoyed now. Are we really in 21 century?

  • H:outputLink tag whitespace

    Hello,
    I've found that the <h:outputLink> tag, when rendering HTML, follows the closing </a> with lots of whitespace - some line breaks and tabs. I'm not sure if this problem is specific to the particular JSF implementation I'm using (WebSphere Portal v5.1 JSF Portlet).
    This is a problem because we need some of our links to be immediately followed by a period. With any whitespace there, the browser renders a single space between the link and the period.
    Any ideas on how to fix this?
    Thanks

    Adding the CSS style of "whitespace: normal;" doesn't really do anything, since it's the normal way the browser interprets whitespace - multiple continguous whitespace in the HTML gets rendered as a single space. What I need is to not have any spaces rendered.
    It's too bad there isn't a CSS style that makes whitespace in the HTML completely ignored.
    I'm still looking for a solution here. I could probably take out the h:outputLink tag and just use an <a href=" in my JSP, but I would much prefer to use a JSF tag if possible. Especially since this kind of situation appears in many places in our application.

  • Generated javascript by JSF doesn't works with IE

    Hi Everyone!!!
    I Have a big problem, the jaavascript code generated by JSF doesn't
    works using IE, I used a h:commanLink with actionListener to a funciton
    in the backing bean, and I use two f:params to send the parameter of an
    specific element to show its details, the problem is taht the
    javascript code generated shows an error: "
    'documents.forms.form.form:_idcl' is null or is not an object " or "
    'elements.idVar' is null or is not an object ". I'm not using MyFaces,
    or something similar because the application has a part built in
    ArcgisServer, and it 's not compatible with Myfaces, so I needed to use
    JSf only...
    Please I hope an answer, it has a big problem!!!
    it is the code of the jsp
    <code><h:commandLink actionListener="#{consultaEstadisticasMB.detalleEstadistica}">
    <f:param name="idVar" value="#{consultaEstadisticasMB.idColumna3}"/>
    <f:param name="idMun" value="#{registro[0]}" />
    <h:outputText title="#{consultaEstadisticasMB.columna3}" id="itColumna3" value="#{registro[2]}" />
    </h:commandLink>
    </code>

    Minor nit: MyFaces is JSF, an implementation at least, as is Mojarra, which I assume is what you mean. :)ye, MyFaces is an implementation... but at this time, we�re using "JSF 1.1.02 - Reference Implementation"...
    Now, I have noticed that is a problem of jsf implementation so i have tried to do the work in another way, usign outputLink, nad creating a new backing bean for the details page.. altough I'm having problems, this is what i'm trying to do:
    <h:outputLink value="/ConsultaEstadisticasGeo/detalleEstadisticas.jsf?idVar=#{consultaEstadisticasMB.idColumna3}">
              <h:outputText title="#{consultaEstadisticasMB.columna3}"id="itColumna3" value="#{registro[2]}" />
    </h:outputLink>but it shows me an error...
    GRAVE: Servlet.service() para servlet Faces Servlet lanz� excepci�n
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    And I don't kwon why. If you could help me, I would been so grateful

Maybe you are looking for

  • Problema com Lançamento de Custos Complementares na MIGO

    Boa Tarde pessoal, tudo bom? Estou escrevendo aqui no Grupos para ver se alguem pode me ajudar. Aqui na empresa onde estou trabalhando estamos com um caso muito estranho acontecendo em alguns pedidos. E o pior o caso acontece de forma intrmitente, ou

  • Issue with opening and closing 13 inch MBP

    I recently received a 13 inch 8gb memory Macbook pro for educational purposes. Although I believe it is overall a great product, I have noticed an issue pertaining to opening and closing the device. Occasionally when I attempt to open the device, I n

  • How to trigger unread emails for a given period ?

    Hello All, I kindly need your help on the following. I have a mailbox that receives huge number of emails per day , I`m processing those all unread emails every one minute using a third party tool and make them read after successfull processing , my

  • Manipulating fields in a view

    I have a table with a date and a time and I really need that data in a datetimestamp format.  I'm trying to avoid creating a custom table and a custom program to get this information that already exists in this table. If I put the data in a view, is

  • Change the field object location in crystal report

    hello, i want to change the contols location in crystal report and the controls alignment in run time to make mirror ,how can i access this controls and this properties. we use two language English and arabic that have different alignment. thanks and