Results 1 to 6 of 6

Thread: JSF example url? Parameter Help!!

  1. #1
    Join Date
    Jan 2010
    Posts
    76

    JSF example url? Parameter Help!!

    I have just begun to concern myself with JSF and came across the following problem that I have an application via a URL and GET parameters call start () and thus would then want to continue working. Various examples of myfaces.apache.org etc. already searched but unfortunately found anything suitable I found an example in the form of a so-called front controller, but unfortunately I do not get to run.. This time the problem File:
    Code:
    public class Controller extends HttpServlet (Front 
    
    Application private Factory factory; 
    private Application application; 
    
    
    /* 
    * Initialization of the servlet. 
    */ 
    public void init () throws ServletException ( 
    factory = (Application Factory) FactoryFinder.getFactory ( 
    FactoryFinder.APPLICATION_FACTORY); 
    factory.getApplication application = (); 
    ) 
    
    /* 
    * Implementation of the GET method 
    */ 
    protected void doGet (HttpServletRequest req, HttpServletResponse res) 
    throws ServletException, IOException ( 
    
    Object obj = req.getParameter ("param1"); 
    String param1 = (obj! = Null)? obj.toString (): ""; 
    
    obj = req.getParameter ("param2"); 
    String param2 = (obj! = Null)? obj.toString (): ""; 
    
    RepositoryBean pBean RepositoryBean = new (); 
    pBean.setParam1 (param1); 
    pBean.setParam2 (param2); 
    
    Faces Context jsfContext = FacesContext.getCurrentInstance (); 
    ELContext elContext jsfContext.getELContext = () // !!!!!!! 
    Application application = jsfContext.getApplication (); 
    Value Expression vExpr application.getExpressionFactory = () //!!!!! 
    .CreateValueExpression (elContext, "# (RepositoryBean)", 
    RepositoryBean.class); 
    vExpr.setValue elContext (pBean); 
    
    RequestDispatcher rd = 
    getServletContext ().getRequestDispatcher ("/ start.jsp"); 
    rd.forward (req, res); 
    ) 
    )
    Has anyone since perhaps time a tip or possible even a working example .... Please help me to sort out my problem.

  2. #2
    Join Date
    Mar 2008
    Posts
    227

    Re: JSF example url? Parameter Help!!

    Because one would have to create a workaround NEN since in a Non-Faces-Request to a Faces request, he immediately spring to Render Response phase and render the page -> is articulated in such an initial request did not touched the model. Maybe someone has a suggestion for a workaround or had this problem.!!

  3. #3
    Join Date
    Mar 2008
    Posts
    258

    Re: JSF example url? Parameter Help!!

    I have just rummaged in my old code. I have always picked up the parameters in the constructor of the bean (which is of course not in session beans, since the C'tor is not always called).
    Code:
    public class Bean 
    ( 
    public Bean () 
    ( 
    Map requestMap context.getExternalContext = (). GetRequestParameterMap (); 
    // Then you can on the GET parameters for easy access 
    / RequestMap.get ("paramName"); 
    ) 
    )
    For this to work in POST requests when the page is sent, then I'm quite ugly with the parameters
    <Input type = "hidden" name = "paramName" value = '<html:outputText value="#{param['paramName]}" />' />
    re-enabled.

  4. #4
    Join Date
    Oct 2008
    Posts
    167

    Re: JSF example url? Parameter Help!!

    You can alternatively times with JBoss Seam experiment, which have extended the standard JSF and the entire Design Flaws. Otherwise I wish you much fun with the following problems :
    • Parts are too rigid:
      • Last line for a table differently, for example, summing
      • Colspan on columns
    • Not work well with JSP / JSTL, Servlet Spec only have 2.5
    • Performance (especially at Sun reference implementation)
    • Expression Language to the weak (method call with parameters)
    • Too weak Controller
      • navigation rules are not binding

  5. #5
    Join Date
    Dec 2008
    Posts
    202

    Re: JSF example url? Parameter Help!!

    Can also use a normal output link you just ... but basically all this is less beautiful, because content of the Faces Lifecycle is first left, only to enter it right after again. The advantage of this get-parameters is that the links will be bookmark-able ... external servlets or whatever you can respond like so ... but you should think about why you want to do that at all ... a command link should remain the first choice for JSF ... - Chic is indeed the approach since in Grails - but no matter

  6. #6
    Join Date
    Feb 2010
    Posts
    182

    Re: JSF example url? Parameter Help!!

    I've written in such an example with an "extra" phase listener.
    Code:
     / ** 
    * @ See # javax.faces.event.PhaseListener beforePhase (javax.faces.event.PhaseEvent) 
    * / 
    public void beforePhase (Phase Event event) ( 
    logger.debug ("Starting set locale"); 
    Faces context = FacesContext.getCurrentInstance (); 
    Map requestParams context.getExternalContext = (). GetRequestParameterMap (); 
    Map sessionParam context.getExternalContext = (). GetSessionMap (); 
    String language = ""; 
    if (requestParams.containsKey ("language")) ( 
    language = (String) requestParams.get ("language"); 
    sessionParams.put ("language", language); 
    setLanguage (language); 
    if (logger.isDebugEnabled ()) ( 
    logger.debug ("locale found in request parameter:" + language); 
    ) 
    ) Else if (sessionParams.containsKey ("language")) ( 
    language = (String) sessionParams.get ("language"); 
    setLanguage (language); 
    if (logger.isDebugEnabled ()) ( 
    logger.debug ("locale found in session parameter:" + language); 
    ) 
    ) 
    )

Similar Threads

  1. Method does not receive parameter
    By Beverly Archer in forum Software Development
    Replies: 5
    Last Post: 11-03-2010, 11:48 AM
  2. Matrix parameter function
    By Chrisch in forum Software Development
    Replies: 3
    Last Post: 02-12-2009, 11:07 AM
  3. javascript add parameter to url
    By purvagarg in forum Software Development
    Replies: 3
    Last Post: 23-07-2009, 08:04 PM
  4. What is parameter tampering ?
    By Anathakrishnan in forum Technology & Internet
    Replies: 5
    Last Post: 21-04-2009, 09:25 AM
  5. Parameter is incorrect
    By Packham in forum Media Player
    Replies: 3
    Last Post: 09-12-2008, 08:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,614,325.86053 seconds with 17 queries