Dynamic JSF GUI

Hi
I have a problem with creating dynamic GUIs. I have tried it the way it is described in Hans Bergstens book chapter 15, but it does not work. This may be because I am using WebSphere Application Developer 5.1.2 with a Tomcat 4.0.6.2 plugin. I do always get an "java.lang.IllegalStateException" when performing the second code line:
ServletResponse response = (ServletResponse)context.getExternalContext().getResponse();
OutputStream os = response.getOutputStream();" //Error is generated
BUT there seems to be a slightly different way to generate dynamic user GUIs. This looks like this:
//begin
HtmlPanelGrid grid = new HtmlPanelGrid();
HtmlOutputText title = new HtmlOutputText();
title.setValue("This is my component!");grid.getChildren().add(title);
//end
I have just seen that code in this forum and I have no idea what I should make with it. How does it work to make a GUI this way? How and where is it rendered?
Thanks

What I need is a JSP that has a tag which should look like this:
<pre>
<f:view>
<hx:scriptCollector id="scriptCollector1">
<h:form styleClass="form" id="form1">
<myTag: generateGUI />
</h:form>
</hx:scriptCollector>
</f:view>
</pre>
Alternatively it would be possible to use something else than a tag.
The Tag should then be able to generate the GUI.
<pre>
public class GUITag extends TagSupport
public int doStartTag()
HtmlCommandButton button = new HtmlCommandButton();
button.setId("myButton1");
button.setValue("button");
MethodBinding mbButton = application.createMethodBinding("#{InputValueChanged.print}", null);
button.setAction(mbButton);
component.getAttributes().put("action", mbButton);
//try
button.encodeBegin(facesContext);
button.encodeChildren(facesContext);
button.encodeEnd(facesContext);
//catch block
</pre>
So for example here a button should be generated in the GUI. This button should work. This means when pressing the button the print method of the InputValueChangedBean should be performed. And this does not work at the moment.
The important thing is that the JSP must not contain any JSF code like:
<pre>
<h:outputText ....
</h:outputText>
</pre>
This is because at the beginning of the JSP rendering process I have no idea which components are going to be displayed on it. What will be displayed on the JSP stands in an XML file. This XML file does not only contain the GUI information for one page, it does contain all the GUI information for the entire WebApplication. Depending on which button the user clicks on the dynamically generated GUI a different part of that XML file will be rendered (made to a GUI). So the user sees something different.
I have also thought about using a custom presentation layer as described in chapter 15 of your book. But as far as I have understood that I have to create a ViewHandler. As a result of that the entire GUI of the WebApplication is then rendered using that ViewHandler. And this means I am not longer able to use normal JSPs (I would need to use the ViewHandler and normal JSPs together. So one part of the WebApplication should be rendered using the ViewHandler and the other part of the WebApplication should consist of normal JSPs).
Is there any possibility having one part of the WebApplication rendered by the information of an XML file and a different part of the same WebApplication to be rendered the normal way by using JSPs with JSF tags?

Similar Messages

  • Dynamic JSF GUI and associated backingbeans

    I'm designing a web application using JSF. One of the main requirements is that our GUI needs to be pluggable. I have tried to understand how pluggability can be achieved in JSF but haven't found a clear solution.
    I would like the application to be packaged as a war file. Adding customer specific pages/bean classes to the war file and repackaging of the war is not an option. The customer specific pages/classes must reside outside this war. At runtime, based on configured rules, I need to load the customer pages and render them. If the pages are JSP based JSF pages, then they will also have their associated backing beans.
    Given that the backing beans must be preconfigured as managed beans in the faces-config.xml file and all JSP pages must be part of the packaged web application, I don't know how to go about doing this.
    A solution (non-ideal) that I have thought of is to have the customers design their forms as HTML pages and have them put these forms in the document root directory on the app server. The customer code that manipulates the data on the form will be packaged in a jar file. The HTML form 'action' will be set to a URL that will take them to one of my servlets. The interaction will be such:
    1. A user visits my JSF/JSP page. He clicks on a button. In the action event listener, I decide on the correct html form to forward the request to. I put the instance of the backingbean class in the HttpSession and forward the request to the HTML page.
    2. The browser displays the HTML form. The user enters data on the form and submits it. The request arrives at my servlet.
    3. My servlet instantiates the appropriate customer class (using the ClassLoader) and calls a method on it passing it all postdata; the method returns some String value. The servlet pulls out the backingbean class instance from the HttpSession and calls a setProperty(String value) on it. The servlet then gets a handle to the RequestDispatcher and forwards the request to my original JSF/JSP page.
    4. The JSF page is rendered in the browser with then new value (property set by the servlet) displayed in the right view component.
    The above approach is very messy and with many customer forms and backend classes this approach can get very ugly. I am looking for the correct solution that is recommended by JSF to achieve this kind of pluggability.
    Any thoughts, advice or feedback will be very appreciated.
    thanks,
    tsc

    I have researched my issue online for quite some time and have found nothing that jumps out except one post to this forum.
    Adam.Winer replied to a similar post on this forum over a year ago where he suggests replacing the ViewHandler, NavigationHandler and VariableResolver to be able to plugin JSP pages at runtime (See below).
    After doing some reading, I understand the function of the NavigationHandler and VariableResolver a bit better. do not understand how to replace the ViewHandler and what the new handler should do to render different JSP pages at runtime.
    Has anyone tried this approach. If yes, examples would be nice.
    I'm sure what I'm attempting has been done before many times. How have people gone about to achieve this kinda of pluggability in JSF.
    Anyone?
    From: http://forum.java.sun.com/thread.jspa?forumID=427&threadID=524937
    Re: dynamic configuration for the application
    adam.winer Registered: Dec 23, 2003 12:00 AM      May 24, 2004 9:30 PM
    A lot of what you're seeing are genuine limitations, but happily, JSF is so pluggable that you can overcome them.
    JSPs are problematic in exactly the way you describe - unless your app server has support for pulling JSPs out of a database, etc., you're SOL. JSF, however, lets you use something other than JSPs by replacing the ViewHandler. That's a fair bit of work, but it is doable.
    For navigation logic, you'd replace the NavigationHandler. As long as you're willing to write the code that can pull navigation rules from an external source, life is good.
    For managed beans, all you need to replace is the VariableResolver - again, if you can pull the rules from an external source, you have full control.
    This is all far from easy - and it's a huge amount of work for one person - but I'd imagine these pieces will become available from various sources. A core goal of JSF 1.0 was making the framework as a whole pluggable so that others can innovate on top of the framework.
    -- Adam Winer (EG member)

  • JSF with in another dynamic JSF - Urgent Help Needed

    Hi,
    When i have JSF with in another dynamic JSF it worked fine in weblogic 9.2. But in weblogic 10.3.2 it is thwoing illegal state exception. Ho w can i add another JSP?
    <h:form id="frmAssignImpersonate">
         <h:inputHidden id="hiddenSoxEditPrivilege" value="#{assignImpersonate.soxEditPrivilege}"/>
         <h:inputHidden id="donotdelete" value="#{assignImpersonate.donotDelete}"/>
         <table class="TableContentWhite" style="TABLE-LAYOUT: fixed" cellSpacing="0" cellPadding="0" width="400">
              <tr>
                   <td>
                   <jsp:include page="/jsf/common/a.jsp"flush="false"/>
                   </td>
              </tr>
         </table>
         <table cellpadding="0" cellspacing="0" border="0" align="left" width="500">
              <TR class="ColorModuleHeader" height="20">
                   <TD class="rowHdr" align="left">Assign Impersonation Rights</TD>
              </TR>
              <tr>
                   <td valign="top" Class="TableContentwhite" align="left">
                   <jsp:include page="/jsf/common/b.jsp"flush="false"/>
                   </td>
              </tr>
         </table>
    </h:form>
    <%@ include file="/jsf/common/bdeFooter.jsp" %>
    Exception:
    java.lang.IllegalStateException
         at com.sun.faces.taglib.jsf_core.ViewTag.getComponentType(ViewTag.java:258)
         at javax.faces.webapp.UIComponentELTag.createComponent(UIComponentELTag.java:215)
         at javax.faces.webapp.UIComponentClassicTagBase.createChild(UIComponentClassicTagBase.java:466)
         at javax.faces.webapp.UIComponentClassicTagBase.findComponent(UIComponentClassicTagBase.java:651)
         at javax.faces.webapp.UIComponentClassicTagBase.doStartTag(UIComponentClassicTagBase.java:1097)
         Truncated. see log file for complete stacktrace

    wrong forum, you will not get answer here

  • How to build dynamically specified GUIs/Forms

    Dear forum members:
    As Flex newbie I still have got some questions concerning the Flex technology.
    I've got to modernize an existent catalog-based ordering system in which a ShopManager (the 1st kind of enduser and an "enduser programmer" at the same time) shall be able to *declaratively specify* some customer groups, products, product bundles, product- and group-specific prices (via pricing rules) and product selection rules. Then, a customer (2nd kind of enduser) shall be able to place orders through a GUI that behaves exactly as specified before by the ShopManager.
    In a non-enduser-programming scenario I normally would use a MVC-framework (like Cairngorm or Swiz, I guess for the Flex world) and hard-code the controller logic as need.
    The problem I have in this enduser-programming scenario is that I cannot figure out how to transform the declaratively specified behaviour into running controller code!?!!!
    Perhaps a rudimentary example in order to clarify issues:
    Let's say we have a ShopManager and a Customer, and that the "workflow" is as follows:
    A) the ShopManager specifies via his/her ShopManagerTool the following topics, ignoring further topic-specic properties for now:
       1. customer_groups = {cg01, cg02}
       2. products = {prodA, prodB, prodC}
       3. product_bundles = {{bundle01, prodA, prodB}, {bundle02, prodB, prodC}}
       4. price_rules = {
                            //atomic product prices, cgroup-specific:  (*1)
                            price_rule(cg01, prodA, 20.00USD),        
                            price_rule(cg02, prodA, 18.00USD),
                            price_rule(cg01, prodB, 25.00USD),
                            price_rule(cg02, prodB, 22.00USD),
                            price_rule(cg01, prodC, 30.00USD),
                            price_rule(cg02, prodC, 27.00USD),
                            //bundle prices, cgroup-specific:
                            price_rule(cg01, bundle01, 39.99USD),
                            price_rule(cg02, bundle01, 37.99USD),
                            price_rule(cg01, bundle02, 59.99USD),
                            price_rule(cg02, bundle02, 55.99USD),
       5. selection_rules = {                                           
                            sel_rule(cg01, dependsOn(prodC, prodA)),   (*2)
                            sel_rule(ALL , dependsOn(prodC, prodB)),
                            sel_rule(ALL , includes(prodA, prodC)),    (*3)
                            sel_rule(ALL , excludes(bundle01, prodC)), (*4)
    B) the Customer uses the ordering GUI to select products and/or bundles and place his/her order.
        The GUI components always follow the pricing and presentation/selection rules imposed by the ShopManager specification done before.
    Explanations:
    (*1) This is a kind of pricing matrix and should be obvious.
    (*2) This selection rules should be read as follows:
         (*2) "for cg01 holds: whenever he selects prodA then prodC becomes selectable (as prodC depends on the selection of prodA)".
         (*3) "for all customer groups: the selection of prodA automatically includes prodC".
         (*4) "for all customer groups: the selection of bundle01 automatically excludes prodC".
    That's basically the kind of app to realize, and as far as I can figure it out with my current Flex-understanding, I'll need some model element classes (Product, Customer, CustomerGroup, RuleSet, Rule, PricingRule, SelectionRule, etc.) used by the ShopManager to specify things, and further also let him define some kind of "model element (property) to view element (property)" mapping for visualizing the specifications.
    1. How could this problem be solved the best way? I.e., what would an appropriate solution architecture look like?
    2. How would I transform the declarative ShopManager specifications into concrete MVC code in general and into concrete controller code
    in particular?
    3. Could anyone of you provide me with a rudimentary example of such "dynamically specified forms"?
    Please, due to the current importance of these issues, I would be very very thankful for any helpful solution hints.
    Thank you very much in advance.
    Best regards
        Alessandro

    Dear Adobe (Flex) Forum Members:
    Really no ideas for this topic?
    I would appreciate any solution hints very much -- even pretty simplistic ones.
    Thank you a million in advance.
    Best regards
       Alessandro

  • Need HOW-TO on dynamic JSF pages

    How can we change a page dynamically? For example, I want to create an image tag but I do not know the name of the image until runtime. In fact it is a temporary file name that is geneated by a servlet .
    If this was a standard JSP page I would create a JSP tag with a "name" property . Can JSP tags be used on JSP pages and if so where do they show up in the Creator IDE?

    A technique that I have achieved in my app is to set the image url dynamically through the image url like this...
    THIS ONLY WORKS IF YOU HAVE USERNAME OR SIMILIAR FOR CLIENT SET IN SESSIONBEAN1 (JDBC/LDAP, Login, etc...)
    1. Close Creator locate an example jpeg that you want to bind dynamically.
    2. Open your Projects directory (outside of Creator is how I did) navigate to web/resources make an images directory inside of resources.
    3.Rename your example image something like...
    template1username.jpg
    (Hope I don't have to say that above username will correspond to whatever username you would like to bind the url to so when they are logged into your app they will have dynamic image just for them)
    4. Paste the renamed jpeg into the newly created images directory.
    5. Go back into Creator open your app and drop an image component onto the page.
    6. Make sure it is selected and go to properties pane -- url -- click the ellipses.
    7. NOTE I tried to use property binding and Creator wouldn't retain my url.
    8. Go to Use Value and then navigate to the images directory to the example renamed jpeg and select it so the url displays on top.
    9. Now all you have to do is manually add the binding in the url this way Creator doesn't seem to complain and the JSF Tag remains in the url
    10. To add the binding manually just replace username with the necessary binding expression for me it was...
    /resources/images/template1#{SessionBean1.loginBean.username}.jpg
    now run the project once logged in navigate to page with bound image and voila! It should be there and now all you have to do is add the images properly renamed to the images folder and anybody with a username and corresponding image in the directory gets a personalized image when they are logged in. This is probably not the best way to do this, but for what I was trying to achieve coupled with the fact that I am a NOOB it works pretty darn good.

  • Dynamic  -  JSF

    Hi
    I'm trying to make a JSF dynamic page with a DataTable
    I'm trying to simplify data access activities to dynamic pages implementing this type of architecture :
    http://www.jsfcentral.com/articles/dynamic_jsf-2.html
    I have found a great tutorial with this architecture approach in Oracle site :
    http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html
    But I can't make it work, I don't know how to integrate this with a Managed Bean for UI actions
    I mean
    imagine a inputbox where I enter some text, and a button that will populate dynamically a DataTable making a query to my Model architecture
    Can someone help me, or give me some tutorial ?
    Thank you very much for any help

    Well...finally...I was able to make it work
    following the tutorial I said in the above post :
    http://www.oracle.com/technology/oramag/oracle/06-jan/o16jsf.html
    I was able to generate a static datatable, but I can't do the "Part 2: Creating a Data Table, Using the JSF API"
    I'm interested in making a dynamic query, the problem is with commandButton_action method - Code Listing 6
    I get a lot of errors :
    Type or variable 'column1' not found
    Type or variable 'column2' not found
    Type or variable 'column3' not found
    Type or variable 'column4' not found
    Type or variable 'column5' not found
    Type or variable 'column6' not found
    I included this declaration lines :
    UIColumn column1 = new UIColumn();
    UIColumn column2 = new UIColumn();
    UIColumn column3 = new UIColumn();
    UIColumn column4 = new UIColumn();
    UIColumn column5 = new UIColumn();
    UIColumn column6 = new UIColumn();
    And made a new import statement
    import javax.faces.component.UIColumn;
    but I can't populate my dataTable...the result is just like a very small "icon" empty datatable, I tried to change the dataTable width but without success
    What's wrong ?

  • Is there any Dynamic JSF tab component support?

    It seems that there're some JSF implementation support tab instead of JSF RI. but the way they work are wirte the static tags in the jsp.but my situation is -----
    dynamicly create tabs according to data, where means if there is 3 options, then make to tabs. if 3, then 3 -----
    if there any support out there somewhere? thanks!!

    The Scales and Tomahawk libraries provides a tabbed panel.
    But basically tabs are nothing less or more than a bunch of block elements layered over each other with the same amount of buttons or links at the top. If a tab click doesn't require a trip to the server, then you can just load all tab blocks at once and use Javascript+DOM to switch between tab blocks, e.g. one block should be displayed using element.style.display='block' and all other blocks should be hidden using element.style.display='none'. If a tab click require a trip to the server (to preinitialize stuff or so), then you can use the 'rendered' property of the tab block element (which can be <h:panelGroup style="display:block;" rendered="#{myBean.showTab == 1}" /> or so).
    For styling of the tab blocks and tab buttons/links just use CSS.

  • How to make an opion to add and remove portlets dynamically from GUI?

    Hi,
    I have a requirment to provide option for the users to remove some section (basically portlets) from the page and add it later based on preferences .I think currenlty we have this option in iGoogle website. please give me some pointers towards the solution.?
    Thanks Jazz

    Hello Jazz,
    If the "preferences" you are referring to are the users' preferences (and not "portlet preferences"), I think the Dynamic Visitor Tools are what you want. There is a demonstration of the dynamic visitor tools at:
    http://wlp.oracle.com/dvt/appmanager/demo/dvt
    Kevin

  • Defining variant for report for job with dynamic date Gui 6.40 patch 21

    The system does not take over my choice for the dynamic date.
    I choose in the variant-attirubute-screen for a certain parameter: "type selection variable": D and then in the column "name of the variable" > I choose via F4: current date +/- days. OK and then I fill in 1 or 1- or whatever.  The system however does only react with the message "Upper date of the interval is > than upper date". It does not matteer what I choose.
    In the initialization I do not have any initialization of that parameter.
    I connot save the variant.

    Go through this link...
    http://help.sap.com/saphelp_47x200/helpdata/en/d1/802cfc454211d189710000e8322d00/frameset.htm
    In this page
    ABAP Workbench tools -->
                      VARIANTS  -->
                            VARIABLE VALUES IN VARIANTS.
    Hope this helps u a lot...
    reward if it helps u...
    sai ramesh.

  • Dynamic JSF Content

    i need to write an html output stream to a JSF page and then include that page in another JSF page which will be the root page. Is this possible, and if so what can I attach links to these pages so that they can be viewed independently from the main/root page?
    Thanks, any help appreciated.

    well i came up with another idea but for some reason it doesn't work. The alternative idea that I came up with was to load the other page in an iframe and just put the iframe on the main page. Now I do not know if the fact that the page loading in the iframe submits to itself and writes the output to itself would keep it from being loaded in an iframe or not. Any ideas?
    Thanks.

  • Dynamic Converter GUI Templates with IDOC

    Hello, is there any way to use IDOC script in GUI Templates?
    We have XML document and need to convert it to HTML. We can use XSL or GUI Templates.
    The problem is - XML document has elements which need to be referenced with Content Server View. For example we have XML element called CODE:
    <XML>
    <CODE>10</CODE>
    </XML>
    There is view in Content Server with two columns CODE, DESCRIPTION:
    CODE: 10
    DESCRIPTION: Description for code 10.
    I need to render Description column value on converted HTML.
    Any thoughts how to achieve that would be appreciated..

    try uninstall and insatall the component again. Also logout and login
    regards,
    deepak

  • Creating dynamic jsf page from xml

    I have an xml file with repeating content and from this xml file I have to build a screen with what is in the XML file
    The following is a sample of what I am talking about .I would have two RequestItem sections on the screen with a field ItemId ,RequestAction,
    Level,TelephoneNumber etc.
    The problem I face is knowing how many RequestItemes are in the XML .
    Any Ideas what is the best way to approach this .
    <RequestItem>
    <ItemId>3</ItemId>
    <RequestAction>ADD</RequestAction>
    <Level>LINE</Level>
    <TelephoneNumber>
    <TN>3035552224</TN>
    <CompressionType>729</CompressionType>
    </TelephoneNumber>
    <TenantLocationRecord>
    <Id>tlr1234567891
    </Id>
    </TenantLocationRecord>
    </RequestItem>
    <RequestItem>
    <ItemId>1</ItemId>
    <RequestAction>DELETE</RequestAction>
    <Level>LINE</Level>
    <TelephoneNumber>
    <TN>3035542224</TN>
    <CompressionType>730</CompressionType>
    </TelephoneNumber>
    <TenantLocationRecord>
    <Id>tlr1234567891
    </Id>
    </TenantLocationRecord>
    </RequestItem>

    Use Jaxb to read the XML and then programatically add components to the page.

  • Dynamically changing GUI JPanel

    I have a JFrame which I have added two JPanels to.
    One of the JPanels has JtextFields added to it.
    Is it possible to add/remove JTextFields during runtime?

    awesome! Thanks for that! It works! I am really enjoying writing this application, I thought I might get stuck here :)
    I might just ask this (even though it doesn't matter so much now)
    I have this senario...
    private JPanel main
    private JPanel panel1
    private JPanel panel2
    main.add(panel1)
    main.add(panel2)
    Component comp = main
    JScrollPane sp = new JScrollPane(comp)
    container.add(sp, "Center")
    I am only changing panel2's contents. Can I just remove and add the panel2 on it own? Once again it works if I just make a new instance of panel2 and then add all the components back into the contentpane after the removeAll call.
    Thanks again :)

  • Building the site structure for a dynamic website with JSF

    Hi,
    I am still a JSF-beginner.
    I try to build a fully-functional base-demo-application with a fix and a dynamic part.
    Fix part for menu, dynamic part for site-content.
    At the moment, the JSF-hyperlinks of the main menu work, but any JSF-parts in the included documents of the dynamic part are not shown. I guess, this is dued to inclusion of subviews, but I cannot find any similar examples in the web to come one step further.
    Here my complete demo:
    faces-config.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 xmlns="http://java.sun.com/JSF/Configuration">
    <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>site1</from-outcome>
    <to-view-id>/site1.jsp</to-view-id>
    <redirect>
    </redirect>
    </navigation-case>
    </navigation-rule>
    <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
    <from-outcome>site2</from-outcome>
    <to-view-id>/site2.jsp</to-view-id>
    <redirect>
    </redirect>
    </navigation-case>
    </navigation-rule>
    </faces-config>
    web.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <context-param>
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
    </context-param>
    <context-param>
    <param-name>com.sun.faces.validateXml</param-name>
    <param-value>true</param-value>
    </context-param>
    <context-param>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
    </context-param>
    <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <session-config>
    <session-timeout>
    30
    </session-timeout>
    </session-config>
    <welcome-file-list>
         <welcome-file>
    index.jsp
    </welcome-file>
    </welcome-file-list>
    </web-app>
    index.jsp:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <% response.sendRedirect("/jsfportal/site1.jsf"); %>
    site1.jsp:
    <?xml version="1.0" encoding="UTF-8" ?>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <% String site = "1"; %>
    <%@ include file="base.jsp" %>
    dynamic_site1.jsp:
    <h1>Welcome to site 1</h1>
    Have fun visiting our portal
    site2.jsp:
    <?xml version="1.0" encoding="UTF-8" ?>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <% String site = "2"; %>
    <%@ include file="base.jsp" %>
    dynamic_site2.jsp:
    <h1>Welcome to site 2</h2>
    Go to site 1: *<!-- And this is the JSF-link that is NOT shown: -->*
    <f:view>
    <h:form>
    <h:panelGrid border="0" columns="0">
    <h:commandLink id="p1" action="site1" value="Site 1" />
    </h:panelGrid>
    </h:form>
    </f:view>
    base.jsp:
    <%@ page language="java" %>
    <%@ page import = "java.io.*" %>
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%
    String title = "";
    int siteInteger = 0;
    String dynamic_site = "";
    if ( site != null )
    if (
    ( site.length ( ) > 0 )
    ( site.length ( ) <= 30 )
    if ( isNumeric ( site ) )
    siteInteger = Integer.valueOf ( site ).intValue ( );
    switch ( siteInteger )
    case 2: title = "Site 2";
    dynamic_site = "dynamic_site2.jsp";
    break;
    default:
    title = "Site 1";
    dynamic_site = "dynamic_site1.jsp"; // Start page
    %>
    <html xmlns="http://www.w3.org/1999/xhtml"
    lang="de" xml:lang="de">
    <head>
    <title>
    <%= title %>
    </title>
    <meta name="description" content="test site" />
    <meta name="keywords" content="test site" />
    </head>
    <body>
    <div width="100%" style="text-align:left">
    <table width="970" border="0" cellspacing="0" cellpadding="0" style="background-color:#ffffaa;margin-top:25px;">
    *<!-- this is not good style putting CSS directly into HTML but it is a demo now ;) -->*
    <colgroup>
    <col width="970" />
    </colgroup>
    <tr>
    <td valign="top" align="left" style="padding:25px;">
    +<h1>+
    JSF portal
    +</h1>+
    </td>
    </tr>
    </table>
    <table width="970" border="2" cellspacing="0" cellpadding="0" style="background-color:#f5f5f0">
    <colgroup>
    <col width="270" />
    <col width="700" />
    </colgroup>
    <tr>
    <td valign="top" align="left" style="padding:25px; padding-left:40px;padding-bottom:320px;">
    <f:view>
    <h:form>
    <h:panelGrid border="0" columns="0">
    <h:commandLink id="p1" action="site1" value="Site 1" />
    <h:commandLink id="p2" action="site2" value="Site 2" />
    </h:panelGrid>
    </h:form>
    </f:view>
    </td>
    <td valign="top" align="justify" class="haupttext" style="padding:24px;">
    <p align="justify">
    <f:subview id="subview1">
    <jsp:include page="<%= dynamic_site %>" flush="true">
    <jsp:param name="" value="" />
    </jsp:include>
    </f:subview>
    </p>
    </td>
    </tr>
    </table>
    </div>
    </body>
    </html>
    <%!
    public boolean isNumeric ( String myInput )
    if (myInput == null || myInput.length() < 1)
    return false;
    int start = 0;
    if (myInput.charAt(0) == '-')
    start = 1;
    for(int i = start; i < myInput.length(); i++)
    if (!Character.isDigit(myInput.charAt(i)))
    return false;
    return true;
    %>
    Who can name me that code positions responsible for that the JSF link in the dynamic part is not shown?
    It is not that it does not work it is not shown. The JSF tree seems to be cut because of wrong use of view and subview etc.
    (To put view tags in site1.jsp and site2.jsp does not help.)
    (Once having afforded an example it should go... (*Then* with JSTL, external CSS, etc. ;) )
    Dynamical site structure with include files is the big problem at the moment.)
    bye, Maik

    I found your following suggestions for such cases (seems you are the only profound JSF freak in the world...? :-) )
    Switch between subviews in one main page
    http://balusc.blogspot.com/2007/01/dynamic-jsf-subviews.html
    But the main problem for me is that I never find complete examples, but always fragments and it would be important for a beginner to have at least once a complete JSF example over a few subviews, especially here where it is very easy to corrupt the internal tree.
    (Some examples use the subview tags in the calling JSP, some in the called e.g.... Does not matter where to put it? Some use verbatim tags for HTML code outside JSF, some don't... and so on)
    Can anyone give me an URL for a complete example of a JSF site (with all files as possible, I am not very patient, too, but in this case it makes sense to have it entire ;-) ) with dynamic switches of subviews as preferentially used for bigger portal sites?

  • How to dynamically include jsp files using jsf el in include tag ?

    Hi,
    I'm trying to get the jsp file name from my backing bean to use it in an include tag but I can't make it work
    When using this piece of code I can get the generated path
             <h:outputText value="/_partial/#{myBean.jspName}.jsp"/>whereas in this code the jsf el is not replaced by this value.
            <%@ include file="/_partial/#{myBean.jspName}.jsp" %> Have you any idea of how to solve this ? I'm currently developing for J2EE 1.4 platform.     
    Thanks for your help,
    Regards.

    If you're using JSF 1.2 and JSTL 1.2 at a JSP 2.1 environment, then you can just use <jsp:include> with unified EL.
    If you're using JSF 1.1, then you may find this article useful [http://balusc.blogspot.com/2007/01/dynamic-jsf-subviews.html]

Maybe you are looking for