JSF and GET parameters

Hi,
This might be an age old question - but I can't seem to find a nice elegant solution - is there any support in JSF for GET parameters? Are there any plans for this to be included? What can I do in the meantime?

Use the #{param.name} syntax as the value of a property in your managed-bean declaration in the faces-config. Then load from the database in a @PostConstruct method. Then just reference the managed bean normally in your JSP/view. When the first reference occurs the implementation will instantiate the bean, set the property and invoke the @PostConstruct method.

Similar Messages

  • How to save a image with JSF and get your URL

    Hi
    I need to save a image to my file system and get your URL. I�m working with JSF.
    Ex.:
    1� Save a image Cup.jpg on the server
    2� Get your URL
    result: http://www.mysite.com/images/Cup.jpg
    Thanks!!!

    I don't understand what's the problem? Can you please elaborate? Show some code snippets and tell where you stucks on.

  • Problem !! How to upload an file and get parameters on the same form ?

    Hello!
    Is there anyway of getting parameters from an
    text field input in a form like :
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
    on the same form. It is something likethis :
    Form.jsp
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >   
    <input type="text" id="name" name="signinName" />
    <input name="signinFile" id="fileUp" type="file" />   
    <input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
    .//upload the file
    String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
    %>Thanks in advance for any suggestion!!
    All the best!

    You can get the parameter value directly. You can do the following to get the parameter name.
    Directly take the request's input stream and parse the header and findout the value for text field.
    Or you can use apache's file upload utilities and do the following
    DiskFileItemFactory factory = new DiskFileItemFactory();
                   ServletFileUpload upload = new ServletFileUpload(factory);
                   List fileItems = upload.parseRequest(request);
                   Iterator iter = fileItems.iterator();
                   while (iter.hasNext()) {
                        FileItem item = (FileItem) iter.next();
                        if (item.isFormField()) {
         //Form data fields will be displayed here          out.println(item.getFieldName());
         out.println(item.getString());
    All the best..

  • Jsf and getter call

    hi
    I made a jsf page with a selectOneMenu component. here is the code:
    <h:form>
    <f:view>               
         <h:selectOneMenu id="pippo" immediate="true">     
             <f:selectItems value="#{user.items}" />               
         </h:selectOneMenu>               
    </f:view>
    </h:form>the getter method for 'items' add "select" to the menu
    here is the code
    public SelectItem[] getItems() {
         System.out.println("getItems");
         items[0] = new SelectItem("-1", "select");
         System.out.println("end getItems");
         return items;
    }but if I check the log i can see 2 calls for getItems method
    and these 2 calls are in the same fase (render response)
    for example while loading the page:
    [cut]
    09:36:01,046 INFO [STDOUT] BeforePhase: RENDER_RESPONSE 6
    09:36:02,953 INFO [STDOUT] getItems
    09:36:02,953 INFO [STDOUT] end getItems
    09:36:02,953 INFO [STDOUT] getItems
    09:36:02,953 INFO [STDOUT] end getItems
    09:36:02,968 INFO [STDOUT] AfterPhase: RENDER_RESPONSE 6
    [cut]
    why 2 calls?
    i really don't understand.
    what if I have an heavy getter with db connection and so on ?
    thansk a lot!

    giunad wrote:
    even if I don't figure why I have 2 calls in the same phase (the link you sent me talks about several calls during several phases..) ,
    where should I put the logic code?Definitely not in the getter. Or you must introduce lazy loading in there. Usual places are the constructor or initialization block of the bean.
    for example 2 selectOneMenu on cascade where the content of the second menu is function of the first selection ?
    ie country and state, parent and son, category and subcategory.. and so on.In this case, you may find this article useful: [http://balusc.blogspot.com/2007/10/populate-child-menus.html]

  • Set and Get parameters using SAP memory.

    I have an ALV grid list that I want to transfer to a detail report when the user doubleclicks.  I have set up a parameter transaction associated with the detail report.  My problem is the transfer does not take place.  After the "CALL TRANSACTION" the ALV grid list refreshes with none of the previous select-options being used.  Is there further setup I need to do, or is my coding incorrect?  All of the parameter fields have valid values.  I am new to ABAP, so please be fairly specific with you answer.
    ALV Grid code:
    form user_command using r_ucomm     like sy-ucomm
                            rs_selfield type slis_selfield.
      case r_ucomm.
        when '&IC1'.
          read table gt_data index rs_selfield-tabindex into gt_data_drilldown.
          set parameter id 'LIF' field gt_data_drilldown-lifnr.
          set parameter id 'BLN' field gt_data_drilldown-belnr.
          set parameter id 'CHK' field gt_data_drilldown-chect.
          set parameter id 'BES' field gt_data_drilldown-ebeln.
          set parameter id 'BSP' field gt_data_drilldown-ebelp.
          set parameter id 'MAT' field gt_data_drilldown-matnr.
          set parameter id 'WRK' field gt_data_drilldown-werks.
          call transaction 'ZRVRAD' and skip first screen.
      endcase.
    endform.   
    Detail report code:
    start-of-selection.
    all fields are in DATA stmts.
      get parameter id 'LIF' field lifnr.
      get parameter id 'BLN' field belnr.
      get parameter id 'CHK' field chect.
      get parameter id 'BES' field ebeln.
      get parameter id 'BSP' field ebelp.
      get parameter id 'MAT' field matnr.
      get parameter id 'WRK' field werks.
    end-of-selection.
      write:/1 sy-vline,
            lifnr under 'Vendor #',
            35 sy-vline,
            belnr under 'Invoice #',
            50 sy-vline,
            chect under 'Cheque #',
            65 sy-vline,
            belnr under 'PO #'.
      uline.
      uline.
      write:/1 sy-vline,
            chect under 'Item #',
            90 sy-vline,
            matnr under 'Material #',
            105 sy-vline,
            werks under 'Plant'
    Thanks in advance for your help - Jim

    Thanks for the replies.
    Problem was resolved with submit report.  Code is below:
    <u>Calling ALV List program:</u>
    FORM user_command USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
        WHEN '&IC1'.
          READ TABLE gt_data INDEX rs_selfield-tabindex INTO gt_data_drilldown.
          SET PARAMETER ID 'LIF' FIELD gt_data_drilldown-lifnr.
          SET PARAMETER ID 'BLN' FIELD gt_data_drilldown-belnr.
          SET PARAMETER ID 'CHK' FIELD gt_data_drilldown-chect.
          SET PARAMETER ID 'BES' FIELD gt_data_drilldown-ebeln.
          SET PARAMETER ID 'BSP' FIELD gt_data_drilldown-ebelp.
          SET PARAMETER ID 'MAT' FIELD gt_data_drilldown-matnr.
          SET PARAMETER ID 'WRK' FIELD gt_data_drilldown-werks.
          SUBMIT zco_rpt_vra_detail AND RETURN.
          IF sy-subrc <> 0.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    <u>Called program zco_rpt_vra_detail:</u>
    START-OF-SELECTION.
      GET PARAMETER ID 'LIF' FIELD lifnr.
      GET PARAMETER ID 'BLN' FIELD belnr.
      GET PARAMETER ID 'CHK' FIELD chect.
      GET PARAMETER ID 'BES' FIELD ebeln.
      GET PARAMETER ID 'BSP' FIELD ebelp.
      GET PARAMETER ID 'MAT' FIELD matnr.
      GET PARAMETER ID 'WRK' FIELD werks.
    END-OF-SELECTION. 
      WRITE:/1 sy-vline, 'Vendor', 20 sy-vline, 'Vendor #', 35 sy-vline, 'Invoice #',50 sy-vline,
            'Cheque #', 65 sy-vline, 'PO #', 80 sy-vline, 'Item #', 90 sy-vline,
            'Material #', 105 sy-vline, 'Plant'.
      ULINE.
      WRITE: 'MyVendor' UNDER 'Vendor', lifnr UNDER 'Vendor #', belnr UNDER 'Invoice #',
            chect UNDER 'Cheque #', ebeln UNDER 'PO #', ebelp UNDER 'Item #', matnr UNDER 'Material #',
            werks UNDER 'Plant'.

  • Getting and passing parameters in standalone application

    Hi,
    I am calling one java standalone application from another standalone application like the following
    Class c=Class.forName("Ivr");
    Object obj=c.newInstance();
    Ivr h=(Ivr)obj;
    h.service(request,channel);I want to pass and get parameters in both the application.Is it possible in standalone application?
    Thanks.
    Edited by: preethaayyappan on Aug 13, 2008 10:15 PM

    DrLaszloJamf wrote:
    Why didn't you do this?
    Ivr h= new Ivr();
    Indeed much of the posted code in the OP looks like a failed attempt to be "enterprisey".
    @OP Why don't you look at the Javadocs for this Ivr or whatever thing you have there?

  • Problem with SET GET parameters

    Hi all,
    I am facing a problem using SET and GET parameters.
    There is a Z transaction(Dialog program) where some fields of screen are having parameter ID's. That transaction is designed to diaplay/change status of only one inspection lot at a time.
    Now I need to call that transaction in a loop using BDC. I mean i need to update the status of multiple inspection lots(one after the other). Before calling the transaction I am using
    SET PARAMETER ID 'QLS' FIELD lv_prueflos.
    Unfortunately the transaction is only changing the first inspection lot. When I debugged I found that the screen field is changing in PAI. Even though in PBO it shows the next value, when it goes to PAI it is automatically changing to the first value(inspection lot).
    Example: Inspection Lots : 4100000234
                                               4100000235
                                              4100000236
    Now first time when the call transaction is being made the status of insp lot 4100000234 is changed. For the second time when insp lot 4100000235 is being passed in PBO ican see this. But the moment it enters PAI the screen field changes to 4100000234.
    Could you pls help me in solving this issue.
    Thanks,
    Aravind

    Hi,
    Problem with SET GET parameters
    Regarding on your query. Follow this below link.
    It will help you.
    Re: Problem with Set parameter ID
    Re: Problem in Set parameter ID
    I Hope it will helps to you.
    Regards,
    Sekhar

  • Report  using Set parameter & get parameters.

    Hi,
           My requirement is from select query  the list of PO will be display. Now i want when i click on one of the purchase order .
    i want to diaplay PO using CALL TRANSACTION 'ME23N'  with the help of set and get parameters .  or can i do it with interactive report.
    Regards,

    Hi,
    1) Write a Report to show the Output(Use HIDE statment for PO filed while outputing the list).
    2) In the event AT LINE-SELECTION write logic.
    GET CURSOR FIELD field VALUE val.
    SET PARAMETER ID 'BES' FIELD dobj.
    CALL TRANSACTION ME23N.
    Regards,
    J.

  • Getting parameters from text and file input tag. .  canyou help me ?

    Hello!
    Is there anyway of getting parameters from an
    text field input in a form like :
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >Actually I would like to insert the parameters and make the upload of an file
    on the same form. It is something likethis :
    Form.jsp
    <form name="signinForm" method="post" action="uploadFile.jsp" enctype="multipart/form-data" >   
    <input type="text" id="name" name="signinName" />
    <input name="signinFile" id="fileUp" type="file" />   
    <input type="submit" id="submit_btn" name="signinSubmit"/>uploadingFile.jsp
    <%@ page import="java.io.*,javax.servlet.http.HttpServletRequest,javax.servlet.ServletInputStream" %>
    <%@ page import="java.io.FileWriter,java.io.IOException" %>
    <%
    .//upload the file
    String email = request.getParameter("signinName").trim(); //this line is bringing me an NullPointerException
    %>Thanks in advance for any suggestion!!
    All the best!

    You cannot use the HttpServletRequest object to retrieve parameters from a multipart form. You'll have to use a package that can parse such a form. I suggest Apache commons FileUpload.
    http://jakarta.apache.org/commons/fileupload/
    Using this package you can get both the file upload and any other parameters.

  • JSF and bean getter functions

    Hi,
    I'm using a JSP page (say page1.jsp) in which I'm binding the values for some inputTexts to the properties of a Bean (say Bean1).
    <af:inputText id="name" required="true"
                                              showRequired="false"
                                               value="#{Bean1.name}">
               and so on.........Now the first time I call this JSP page (page1.jsp), it calls the get functions of the bean and display the correct value for each InputText.
    However, If I update the values of Bean properties (using some other page) and then again call my first JSP page, the JSP page display some InputText with new values and some with old values..
    I can see that It calls some of the get functions in bean and not calling others, instead using the old values.
    The scope of the bean is - Session
    What can be the possible problem, I'm new to the JSF and not very familiar with it, Is there any way I can force the JSP to call the get function every time for every property in the Bean, I'm using in the page so as to get the current value.

    I'm using Jdeveloper 10.1.3 , and I believe with version 1.1 of JSF

  • How to send data to another site, get response, redirect and get new response

    Dear all,
    I've to write a Java EE application that have to become an interface to a payment platform. The protocol require to send a POST string containing some information (including an error and response page) to an external host, get the response and redirect the user to another host using the previous response. When the user ends the transaction the host redirect the user to my error or response page.
    For the moment my user access to my application using glassfish REALM authentication. After that I write the following code:
    public void paymentPrepare() throws UnsupportedEncodingException, IOException {
       String postUrl = "https://test.payment.test/init/http";
       HttpPost postRequest = new HttpPost(postUrl);
       String id = "99999999";
       String password = "99999999";
       String action = "4";
       String amt = "1.00";
       String currencycode = "978";
       String langid = "ENG";
       String responseurl = "http://myhost:8080/EMBOWorkshop/secure/response.xhtml";
       String errorurl = "http://myhost:8080/EMBOWorkshop/secure/error.xhtml";
      trackid = "TRCK0001";
      udf1 = "Descrizione";
       StringEntity postParamsEntity = new StringEntity("id=" + id
       + "&password=" + password
       + "&action=" + action
       + "&amt=" + amt
       + "&currencycode=" + currencycode
       + "&langid=" + langid
       + "&responseurl=" + responseurl
       + "&errorurl" + errorurl
       + "&trackid" + trackid
       + "&udf1" + udf1);
      postParamsEntity.setContentType("application/x-www-form-urlencoded");
      postRequest.setEntity(postParamsEntity);
       DefaultHttpClient httpClient = new DefaultHttpClient();
       // Execute the HTTP POST
       System.out.println("Executing HTTP Post...\n");
       HttpResponse response = httpClient.execute(postRequest);
       // Check the HTTP status of the post.
       if (response.getStatusLine().getStatusCode() != 200 && response.getStatusLine().getStatusCode() != 201) {
       throw new RuntimeException("Failed: HTTP error code: "
       + response.getStatusLine().getStatusCode());
       // Create a reader to read in the HTTP post results.
       BufferedReader br = new BufferedReader(
       new InputStreamReader((response.getEntity().getContent())));
       // Read in all of the post results into a String.
       String output = "";
       Boolean keepGoing = true;
       while (keepGoing) {
       String currentLine = br.readLine();
       if (currentLine ==
    null) {
      keepGoing = false;
       } else {
      output += currentLine;
       System.out.println("Raw string result: \n" + output);
    The previous code works fine. I receive the response. But now I don't know how to continue. How can redirect the user to another site, and when the payment is finished, receive the response? Another question is, the user authenticate himself to access to the application. When the user will redirect to an external site, the glassfish session permits to get the response from the other host without require a new authentication?
    For the moment I don't know how to redirect the user, but I tried to write this method to obtain the last response:
      public void getResponse(HttpServletRequest request, HttpServletResponse response) {
      paymentId = request.getParameter("paymentid");
      result = request.getParameter("result");
      auth = request.getParameter("auth");
       ref = request.getParameter("ref");
      traind = request.getParameter("tranid");
      trackid = request.getParameter("trackid");
      udf1 = request.getParameter("udf1");
      responsecode = request.getParameter("responsecode");
    Is it correct?
    Thanks

    Now I'm able to redirect the user to the other page:
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("http://stackoverflow.com");
    Now the problem is: once the user has finished to pay, the other site redirect the user to my site using one of the two JSF page I prepared for error or response like the following:
    <?xml version='1.0' encoding='UTF-8' ?>
    <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                    template="./index.xhtml"
                    xmlns:h="http://java.sun.com/jsf/html"
                    xmlns:f="http://java.sun.com/jsf/core"
                    xmlns:rich="http://richfaces.org/rich"
                    xmlns:a4j="http://richfaces.org/a4j"
                    xmlns="http://www.w3.org/1999/xhtml"
                    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                    >
        <ui:define name="content">
            <center>
               An error occurred during  transaction
                #{participantBean.auth}<br />
                #{participantBean.responsecode}
            </center>
      </ui:define>
    </ui:composition>
    So, how can I get the GET parameters that the other host sent to me during the redirection?

  • Jsf with popup window jsf and .xhtml?

    hi,
    HI,
    I am using example at http://www.jsftutorials.net/interface/jsf-popup.html
    for popup with jsf using javascript.
    In main form when click on button or link, i am opening popup window , and getting values
    from popup window to parent window.
    Here I need to pass some parameter or value to popup window without refresh the parent.
    I know with how to do jsp. but i am looking sample
    how to send parameters when we use parent and popup jsf forms with .xhtml.
    Thanks
    siva

    Hi Mainak,
    have a look to Thread:
    Popup Sizing
    As you can see there is not yet a way to set the Popup size.
    You have to find the good combination of fields and length in order to get a nice UI.
    The WDA engine try to set the best size, help it...
    Sergio

  • What is an elegant way to get parameters?

    Is there an elegant way to get parameters?
    I set the id for a parameter on the jsf page and then I can find the parameter by iterating through the parameter map searching the strings until I find the keypair that I need then I grab the value that was submitted on the form.
    For example, I set id=gpaNbr but the string in the parameter map is id0:gpaNbr --- it's got that little "id0:" thingy prepended to the string.
    Can someone suggest a less clumsy technique?
    Thanks,
    Al Malin

    Sorry, forgot to mention it's for JSFs with 10.1.3 dp.

  • How to open a page from a Form and pass parameters to the form on that page

    I found a similar example on this forum, but it did not work for me:
    declare
    l_names owa.vc_arr;
    l_values owa.vc_arr;
    i number;
    begin
    PORTAL.wwpro_api_parameters.retrieve(l_names, l_values);
    FOR i in 1..l_names.count
    LOOP
    htp.p(l_names(i) || ' ' || l_values(i));
    END LOOP;
    end;
    By using this method i get the parameters for the Form, like the session ID, but not the parameters for the Page that the form is displayed in.
    Another method I tried:
    To open a Form from a Form and pass parameters works fine like this:
    --In the After processing page PL/SQL event.
    declare
    v_id number;
    blk varchar2(10):='DEFAULT';
    Begin
    v_id:=p_session.get_value_as_number (p_block_name=&gt;blk,p_attribute_name=&gt;'A_ID');
    if v_id &gt; 0 then
    htp.formOpen('PORTAL.wwa_app_module.link?p_arg_names=_moduleid&p_arg_values=2649500412&p_arg_names=_show_header&p_arg_values=YES&p_arg_names=ID&p_arg_values='||to_char(v_id),'post');
    htp.formSubmit(NULL,'Upload Files');
    htp.formClose;
    end if;
    End;
    But I want to open a Page containing the Form instead of just opening the Form. Is this possible to open a Page and pass paramters to the page, and then let the form inside the Page access the passed paramters. The reason for this is that a Form cannot be based on a page template, or can it? When opening the form i want to keep the left menu, which I can if it is a page based on my template with the left menu.
    Best regards
    Halvor

    Hi,
    You can do this by calling the url of the page with the form. You can then use p_arg_names and p_arg_values to pass parameters. In the called form you can get the value from p_arg_names and p_arg_values and assign it to the form field.
    You can call this code in the success procedure of the calling form.
    declare
    v_id number;
    blk varchar2(10):='DEFAULT';
    v_url varchar2(2000);
    Begin
    v_id:=p_session.get_value_as_number (p_block_name=>blk,p_attribute_name=>'A_ID');
    v_url := <page_url>;
    if v_id > 0 then
    call(v_url||'&p_arg_names=id&p_arg_values='||v_id);
    end if;
    End;
    In the called form in "Before displaying form" plsql section write this code.
    for i in 1..p_arg_names.count loop
    if p_arg_names(i) = 'id' then
    p_session.set_value(
    p_block_name => blk,
    p_attribute_name => 'A_ID',
    p_value => p_arg_values(i)
    end if;
    end loop;
    This code picks up the value from p_arg_values and assigns it to the form field.
    Hope that helps.
    Thanks,
    Sharmila

  • Using SET GET parameters in ITS

    Hi All,
    Is it possible to use set get parameters in ITS. We want to set some parameters in a BADI and read the value in ITS Template .
    Or is there any other method to do this?
    Thanks,
    Anubhav

    Sure. In your abap program use the following code
    *  ITS macros
    INCLUDE avwrtcxm.
    GET PARAMETER ID 'YOUR_PARAMETER' FIELD SAVE_PARAMETER.
    field-set u2018~YOUR_PARAMETERu2019 1 SAVE_PARAMETER.
    field-transport.
    in the template you can now use ~YOUR_PARAMETER.
    regards,
    Klaus
    Edited by: Klaus Layer on Feb 3, 2009 5:05 PM

Maybe you are looking for