Initialize managed bean from request parameters

Hi:
I thought this topic would be on the FAQ, but I couldn't find it. I am looking for a mean to initialize my managed bean from the query string. There must be something like:
<h:form initializeBean=""true"" requestParameter=""id_author"" beanProperty=""#{author.id_author}"" action=""#{author.getFromDB}"" >
</form>
The url would be something like http://localhost:8080/protoJSF/showAuthor.jsf?id_author=5334
And the getFromDB method would be something like
  Public void getFromDB()
     Statement stmt = cn.createStatement( ?SELECT * from author where id_author=? + getId_author() );
     ResultSet rs = stmt.executeQuery();
  }The only way I've found to perform something like this is to present a blank author form with a ''load data'' button: after pressing the button the user can see author's data and edit the data if she wants to. This two-step data screening is annoying, to say the least.
There must be a better way.
I beg for a pointer on how can I achieve the initializing of a managed bean with dynamic data.
Regards
Alberto Gaona

You just have to read carefully the very fun 289 pages
specification :-)Or, if 289 pages of JavaServer Faces is too much, you can get almost all of the same information from the JavaServer Pages 2.0 specification, or even the JSP Standard Tag Libraries specification :-).
More seriously, the standard set of "magic" variable names that JavaServer Faces recognizes is the same as that reognized by the EL implementations in JSP and JSTL. Specifically:
* applicationScope - Map of servlet context attributes
* cooke - Map of cookies in this request
* facesContext - The FacesContext instance for this request
* header - Map of HTTP headers (max one value per header name)
* headerValues - Map of HTTP headers (String array of values per header name)
* initParam - Map of context initialization parameters for this webapp
* param - Map of request parameters (max one value per parameter name)
* paramMap - Map of request parameters (String array of values per parameter name)
* requestScope - Map of request attributes for this request
* sessionScope - Map of session attributes for this request
* view - The UIViewRoot component at the base of the component tree for this view
If you use a simple name other than the ones on this list, JavaServer Faces will search through request attributes, session attributes, and servlet context (application) attributes. If not found, it will then try to use the managed bean facility to create and configure an appropriate bean, and give it back to you.
For extra fun, you can even create your own VariableResolver that can define additional "magic" variable names known to your application, and delegate to the standard VariableResolver for anything else.
Craig McClanahan

Similar Messages

  • Getting bean from request scope

    Hi,
    I am new to JSF and unfortunately I am running into a problem that I am not entirely sure about. I look in other forums and what I am doing looks right but I am not getting the desired result.
    In my faces-config.xml file I have a managed bean defined as follows:
    <managed-bean>
        <managed-bean-name>LogIn</managed-bean-name>
        <managed-bean-class>lex.cac.tables.RefUsers</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
      </managed-bean>I then have a log on page with a form which contains a user name and password field. The tags are defined as
    <h:inputText immediate="false" value="#{LogIn.username}" /> (for username) and
    <h:inputSecret immediate="false" required="true"
                                   value="#{LogIn.password}" /> (for password)
    When I submit the form the web app navigates to a jsp page which attempts to do validation against a database.
    The first step though is retrieving the object which is suppose to be in request scope.
    I attempt the following but I get back null which causes a NullPointerException. Why can't if find the bean?
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    Map params         = ec.getRequestParameterMap();
    params.get("LogIn");  //null is returned hereWhat am i doing wrong? Can someone please help.
    Thanks in advance,
    Alex.

    Something like that:
    FacesContext fc = FacesContext.getCurrentInstance();
    RefUsers LogIn = (RefUsers)fc.getApplication().createValueBinding("#{LogIn}").getValue(fc);
    String username = LogIn.getUsername();
    String password = LogIn.getPassword();

  • Howto: Iterate ADF BC from a managed bean from the View?

    Hi Everyone,
    I've been trying to iterate a BC ADF object from a managed bean from the view layer. Here is what I have done so far, but I don't seem to get any records:
    In faces-config.xml, I am passing in the BindingContext to the managed bean. (This is a session scoped bean).
    <managed-property>
          <property-name>bindings</property-name>
          <property-class>oracle.adf.model.BindingContext</property-class>
          <value>#{data}</value>
        </managed-property>In the testPageDef.xml I have the executables and bindings setup:
      <executables>
        <iterator id="TestRO1Iterator" RangeSize="-1" Binds="TestRO1"
                  DataControl="ApplicationControlDataControl"/>
      </executables>
      <bindings>
        <table id="TestRO1" IterBinding="TestRO1Iterator">
          <AttrNames>
            <Item Value="C1"/>
            <Item Value="C2"/>
          </AttrNames>
        </table>
    </bindings>In my managed bean, in addition to the accessors for the bindingContext of bindings, I have:
                 BindingContainer bc = getBindings().findBindingContainer("testPageDef");
                 ControlBinding cb = bc.getControlBinding("TestRO1");
                 RangeBinding rb = (RangeBinding)cb;
                 List testList = rb.getRangeSet();
                 Iterator testIter = testList.iterator();
                 int testCount = testList.size();
                 while (testIter.hasNext()) {
                   Map attrs = (Map)testIter.next();
                   System.out.println(attrs.get("C1")+","+attrs.get("C2"));     
                   //Do some fancy stuff here with the values.
                 }However, my testList.size() always returns 0.
    Is this the right method to programatically access the data from the view layer from a managed bean, or have I missed something completely? Are there any working samples that I could take a look at?
    Jdev: 10.1.3.1
    Thanks!
    Kenton

    Hi,
    <managed-property>
    <property-name>bindings</property-name>
    <value>#{bindings}</value>
    </managed-property>
    private BindingContainer bindings= null;
    public void setBindings(BindingContainer bc){
    bindings = bc;
    public BindingContainer getBindingContainer(){
    return bindings;
    DCIteratorBinding dciter = (DCIteratorBinding ) bc.get("TestRO1Iterator");
    RowSetIterator rsi = dciter.getRowSetIterator();
    while (rsi.hasNext()){
    Row rw = (Row) rsi.next();
    //Do some fancy stuff here with the values.
    You find several examples in the developer guide and on the Internet
    Frank

  • Cannot get reference to a managed bean from another

    After reading one of BlausC article:
    http://balusc.blogspot.com/2006/06/communication-in-jsf.html#AccessingAnotherManagedBean
    I always get null when I try to get a reference to a session scoped managed bean from a current bean:
    Here is part of the faces context config file:
    <faces-config>
    <managed-bean>
      <managed-bean-name>approvalManagementBean</managed-bean-name>
      <managed-bean-class>com.waseel.waseele.presentation.approval.management.ApprovalManagementBean</managed-bean-class>
      <managed-bean-scope>session</managed-bean-scope>
      <managed-property>
      <property-name>configService</property-name>
      <property-class>com.waseel.waseele.business.config.ConfigService</property-class>
       <value>#{configService}</value>
      </managed-property>
      <managed-property>
       <property-name>approvalService</property-name>
       <property-class>com.waseel.waseele.business.approval.ApprovalService</property-class>
       <value>#{approvalService}</value>
      </managed-property>
      <managed-property>
       <property-name>claimManagementService</property-name>
       <property-class>com.waseel.waseele.business.claim.management.ClaimManagementService</property-class>
       <value>#{claimManagementService}</value>
      </managed-property>
      <managed-property>
       <property-name>codedValuesLoaderServices</property-name>
       <property-class>com.waseel.waseele.business.claim.extraction.loader.codedValuesLoader.CodedValuesLoaderServices</property-class>
       <value>#{codedValue}</value>
      </managed-property>
      <managed-property>
       <property-name>approvalSubmission</property-name>
       <property-class>com.waseel.waseele.business.approval.submission.ApprovalSubmission</property-class>
       <value>#{approvalSubmission}</value>
      </managed-property>
      <managed-property>
       <property-name>payerTpaRelationService</property-name>
       <property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaRelationService</property-class>
       <value>#{payerTpaRelationService}</value>
      </managed-property>
    <managed-property>
    <property-name>payerTpaFiller</property-name>
    <property-class>com.waseel.waseele.business.payerTpaRelation.PayerTpaFiller</property-class>
    <value>#{payerTpaFiller}</value>
    </managed-property>
    </managed-bean>and part of my code:
    public String displayApprovalInEditMode()throws Exception{          
              //This is cross-managed been access; I  need to get the current Approval in the approval management been
              ApprovalManagementBean appMangBean=(ApprovalManagementBean) FacesContext.getCurrentInstance()
                                                      .getExternalContext().getSessionMap().get("approvalManagementBean");What possible problems may be?
    Can any one tell when these session managed beans object get created? is it at start up? or when loading a JSF page that use a bean ?
    becasue this code work in places while not in another

    You must be doing something wrong. I cannot reproduce this problem with the following SSCCE on JSF 1.2_13 at Tomcat 6.0.20.
    Bean1package mypackage;
    public class Bean1 {
        private Bean2 bean2;
        public boolean isBean2Present() {
            return bean2 != null;
        public Bean2 getBean2() {
            return bean2;
        public void setBean2(Bean2 bean2) {
            this.bean2 = bean2;
    }Bean2package mypackage;
    public class Bean2 {
    }JSF<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
    <f:view>
        <html>
            <head>
                <title>Test</title>
            </head>
            <body>
                <h:outputText value="Is bean2 present? #{bean1.bean2Present ? 'yes' : 'no'}" />
           </body>
        </html>
    </f:view>faces-config<?xml version="1.0" encoding="UTF-8"?>
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
        version="1.2">
        <managed-bean>
            <managed-bean-name>bean1</managed-bean-name>
            <managed-bean-class>mypackage.Bean1</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
            <managed-property>
                <property-name>bean2</property-name>
                <value>#{bean2}</value>
            </managed-property>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>bean2</managed-bean-name>
            <managed-bean-class>mypackage.Bean2</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
    </faces-config>It prints 'yes'.

  • Accessing Managed Beans from Code

    Hi,
    How can I access managed beans from my code? I am too new to JSF to know if what I am doing is right from a design perspective. But what I am trying to do is to use Actions as sort of a Web Facade that aggregates state from other beans (all of them Managed beans right now) to build up state that is necessary for displaying pages.
    Thanks for you help
    Suhail

    Just answering my own question. The answer was given in a different thread (http://forum.java.sun.com/thread.jsp?forum=427&thread=427057&message=1901909#1901909) . JSF has provided various Factories (look at the FactoryFinder API) that allow one I presume to access the internal state of a FacesContext. One of the factory is ApplicationFactory. This factory from what I can make out essentially gives you access to everything (actionlisteners, navigationhanlder,components etc) in you application. My original question was about accessing something (for some reason) named ValueBinding. I can access the managed beans declared in my faces-config.xml by invoking getValue(facesContext). I can naturally also set the value of a bean by invoking setValue(...). I just needed the getValue and it seems to work.
    Ofcourse keep in mind that the underlying managed bean will not necessarily be initialized when you access it so test for nullness. As a general rule I think its best not to create the beans but access them using this facility. After all its not for nothing these are called Managed Beans.
    Now if only the faces implementation would persist the changes to Navigation hanlders that one makes in the code ;-)

  • Creation of a Managed Bean in Request Scope?

    Is there an easy way to create an instance of a managed bean (configured in faces-config.xml) that was configured to be in the Request scope?
    If a JSP refers to it by id, then it will be there.
    However, when the JSP does not refer to it, it will not be in the request. I find I need to generate it anyway to use it from within another Managed Bean. I can extract out the faces-config information from the application map (available from FacesContext) and build it manually -- but this ties me to a particular JSF implementation (and probably version, too).
    Is there a more standardized way to do this?
    Thanks,
    ken

    BTW -- I mean to do this from within Java code (not jsp), and the page being rendered does not have a direct reference to the request-scoped managed bean via value binding.

  • Error calling Method on Managed Bean from another Managed Bean

    Hi
    (Jdev 11.1.1.2.0)
    Help please:
    I have a managed bean (page flow scope) which is used by my main page for dynamic region flow navigation:
    *public class RegionNavigationBean implements Serializable{*+
    private String dynamicTaskFlowId = "/WEB-INF/home-task-flow-definition.xml#home-task-flow-definition";+
    *public RegionNavigationBean() {*+
    *public TaskFlowId getDynamicTaskFlowId() {*+
    return TaskFlowId.parse(dynamicTaskFlowId);+
    *public void setDynamicTaskFlowId(String taskFlowId) {*+
    this.dynamicTaskFlowId = taskFlowId;+
    taskFlowId property on main page def is set to +*${pageFlowScope.regionNavigationBean.dynamicTaskFlowId}*+
    In a DB table (i.e. View Object on my model layer) I store a menu ID and a corresponding task_flow_id.
    Then I have created an action listener class (RegionNavigationListener - page flow scope) which I link to my menu items on my main page (action listener property on menu item = +*#{pageFlowScope.regionNavigationAction.processAction}*+ )
    In this action listener (processAction method), I retrieve the row set from the menu VO and find the record which matches my menu ID which caused the action event, thereby retrieving the task_flow_id which must be navigated to.
    I then try to retrieve the instance of the RegionNavigationBean with the following statement: RegionNavigationBean regNav = (RegionNavigationBean)JSFUtils.getManagedBeanValue("regionNavigationBean");+
    This seems to work fine, but as soon as I try and use this I get NullPointerException error, e.g.:
    regNav.setDynamicTaskFlowId(menusRow.gettaskFlowId());+
    or even:
    System.out.println("%%% " + regNav.toString());+
    This is all quite new to me... any help would be appreciated!
    Thanks
    Mario

    Hi Mario,
    I think JSFUtils.getManagedBeanValue(String) has difficult to evaluate the "regionNavigationBean" managed bean.
    What JSFUtils.getManagedBeanValue(String) do is important. I remember that "JSF scoped" bean can be found by JSF style find method, such as requestScope, sessionScope, applicationScope. For a managed bean put in these scope, scope prefix is not needed, for example: using #{beanName} to locate a requestScope bean. The #{requestScope} prefix is not needed.
    But pageFlowScope is different. If a bean is put in the pageFlowScope, you must use #{pageFlowScope.beanName} to locate it.
    Say, ManagedBean is the java class of your manged bean.
    FacesContext ctx = FacesContext.getCurrentInstance();
    Application app = ctx.getApplication();
    ManagedBean mb = (ManagedBean)app.evaluateExpressionGet(ctx, "#{pageFlowScope.managedBeanName}", ManagedBean.class);
    Hope it helps.
    Todd
    Edited by: Todd Bao on Nov 26, 2009 9:58 PM

  • Managing beans based on URL query parameters

    I was just reading this thread with interest, but it didn't come to the conclusion that I need.
    http://forum.java.sun.com/thread.jsp?forum=427&thread=441432
    In that thread, there were two screens: a table of links to employees and an "edit employee" page. The solution was to use the command_action on the list create an "employee data" bean, which could then be edited on the "edit employee" page.
    My problem is that I need to create some session beans based on query parameters in the URL. Using the example above, I'd have something like: http://localhost/app/editEmployee?empNo=38
    Why? Because the user can bookmark the edit employee page, have two
    browser windows open (which would require two seperate employee data beans), etc... and we need to handle that. It looks like
    that means I can't use the solution in the above thread.
    My current thought is to create a managed-bean with request scope and have it create the EmployeeData bean.
    Another idea is to somehow initialize the bean with managed-properties
    <managed-bean>
        <managed-bean-name>EmpBean</managed-bean-name>
        <managed-bean-class>com.mycompany.EmpBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
            <property-name>employeeID</property-name>
            <value-ref>queryParamBean</value-ref>
        </managed-property>
    </managed-bean>
    <!--
      just returns FacesContext.getCurrentInstance().getServletRequest().getParameter("id")
    -->
    <managed-bean>
        <managed-bean-name>queryParamBean</managed-bean-name>
        <managed-bean-class>com.mycompany.QueryParamBean</managed-bean-class>
        <managed-bean-scope>none</managed-bean-scope>but that seems kinda hacky. Any other ideas?

    Excellent, using requestScope gets rid of the queryParamBean hack from my first post. For some reason I thought value-ref evaluatations only resolved against stuff the VariableResolver can see. That's not the case. Thanks.
    Unfortunately, this bean really wants to be cached on the session, not the request. I suppose it would be possible to have EmpBean delegate to a bean which is actually cached on the session, but that feels like a hack too (and is a lot of glue code).
    So, I think I'm back to the factory, which can handle creating the bean from the query params, caching it, and putting it on the servlet request. I also got a visit from Captain Obvious and realized that the factory could just be a scriplet.
    <% BeanCreator.createBean("com.company.EmpBean", request.getParameter("id")); %>which also isn't great, but is perhaps easier to understand than the BeanCreator from above. I looked into using EL Functions in the variable resolver for the factory, but it doesn't look like that's possible. It's probably possible to extend VariableResolver to add factory methods for managed-beans, which might be the cleanest solution. I'm thinking something like
    <managed-bean>
      <managed-bean-name>Emp</managed-bean-name>
      <managed-bean-factory>
         <factory-name>com.company.BeanFactory.getBean</factory-name>
         <bean-class>com.company.EmpBean</bean-class>
         <arg-value-ref>sessionScope.id</arg-value-ref>
      </managed-bean-factory>But for now, the current two hacks are:
    #1: to create a URL use plain html <href>.
    #2: use a factory method (varying implementions) to create the bean, cache it, and put it on the servlet request

  • Have a backing bean in request scope; need to access parameters sent to it

    I have a request scope backing bean in my app, 'projectBean'. This has a property called 'id'.
    /** in request scope in faces-config.xml */
    projectBean {
        id               // set by the param from the previous page
        downloadAction() // activated by commandlink, depends on id
    }There is another backing bean in session scope called 'projectListingBean', which has a dataTable that lists a bunch of projectBeans. In this 'projectListingBean', I can click on any row. That row, when clicked initializes a 'id' parameter, which is then passed to the new 'projectBean'. 'projectBean' then initializes itself based on the id.
    In the jsp page backed by 'projectBean', I also have a link to download something specific to that 'projectBean'. Naturally enough, I have a commandlink with actionBinding to a method in my 'projectBean', downloadXXXAction().
    The problem arises because the downloadXXX() method relies on a 'id'. Remember, this id was orinigally set 2 requests back from the datatable. Since the page backed by 'projectBean' is in request scope, the id is lost, and my method call doesn't work. I tried changing the scope of 'projectBean' to session, but JSF complains that I already setting the 'id' property as a param, I can't set the whole managed bean to something 'higher' like session.
    Of course, the ideal fix to this probelm would be the ability to have beans in page scope, but what other ways (hacks??) are there to get around this?

    Hi, I'm posting some code snippets if it helps with understanding the problem.
    faces-config.xml:
    <!-- PROJECTLISTINGBEAN -->
    <managed-bean>
         <managed-bean-name>projectListingBean</managed-bean-name>
         <managed-bean-scope>session</managed-bean-scope>
         <managed-property>
              <property-name>projectBeans</property-name>
              <property-class>java.util.List</property-class>
              <list-entries>
                   <value-class>
                        com.sun.sleuth.omcmweb.view.bean.ProjectBean
                   </value-class>
              </list-entries>
         </managed-property>
    </managed-bean>
    <!-- PROJECTBEAN -->
    <managed-bean>
         <managed-bean-name>projectBean</managed-bean-name>
         <managed-bean-class>
         </managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
         <managed-property>
              <property-name>projectId</property-name>
              <property-class>java.lang.String</property-class>
              <value>#{param.projectId}</value>
         </managed-property>
    </managed-bean>projectlsting.jsp (page backed by projectListingBean)
    <h:dataTable value="#{projectListingBean.projectBeans}"
         var="projectBean" ...>
         <h:column>
              <f:facet name="header">
              </f:facet>
              <h:commandLink action="#{projectListingBean.viewProjectSUmmary}">
                   <h:outputText value="#{projectBean.projectId}" />
                   <f:param name="projectId" value="#{projectBean.projectId}" />
              </h:commandLink>
         </h:column>
    </h:dataTable>projectsummary.jsp (page backed by request scoped projectBean)
    <h:commandLink action="#{projectBean.assessmentAction}" value="..." />
    ...Flow:
    projectlisting.jsp (projectListingBean - session) -param id passed->
    projectsummary.jsp (projectBean - request) -commandLink clicked and id lost-->
    projectSummary.jsp (projectBean - request)

  • How do you use one managed session bean from another?

    Hello -
    I am a complete newbie to JSF coming from Struts 1. My question is how do you use one managed bean from the method of another one? I think this would be a common senario. For example I put a bean in session scope when a user logs in and in a different method within a different bean I want to get some of this user's information. What is the correct way to retireve one bean from a method in another with session scope?
    Also what would the code look like to retieve another bean from the method of a managed bean where the bean you want to retrieve has application scope?
    Thank you in advance.

    Sinplicity wrote:
    Could you be a bit more specific? If a bean is configured in the faces config file then all of it's properties are managed, correct?Not necessarily.
    What would the code look like to retireve the bean?You don't retrieve it, it has been injected.
    Can I retrieve the whole bean or just a property of the bean. I would be really interested in seeing how this is done in code? And would really love a bit more information on what it means to be a managed property?Time to consult a JSF tutorial.

  • HOWTO: command_button, action and request parameters HOWTO

    Starting from carDetail.jsp example:
    Click of button:
    <h:command_button
    action="#{carstore.storeFrontLuxuryPressed}"
    value="#{bundle.moreButton}" >
    </h:command_button>
    Method Invoked:
    public String storeFrontLuxuryPressed() {
         setCurrentModelName("Luxury");
         return "carDetail";
    Navigation case "carDetail" maps to:
    <navigation-rule>
    <from-view-id>/storeFront.jsp</from-view-id>
    <navigation-case>
    <description>
    Any action that returns "carDetail" on storeFront.jsp should
    cause navigation to carDetail.jsp
    </description>
    <from-outcome>carDetail</from-outcome>
    <to-view-id>/carDetail.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    So I imagine that a forward is done to carDetail.jsp
    At this point I want to daviate from the sample. I would like to pass request parameters to carDetail.jsp
    like:
    carDetail.jsp?mode=create&date=25-Dec-2003
    I want my managed bean in carDetail.jsp to get populated from request scope. The managed bean in config looks something like this:
    <managed-bean>
    <description>this is for item test bean.</description>
    <managed-bean-name>PageParams </managed-bean-name>
    <managed-bean-class> com.a.PageParams</managed-bean-class>
    <managed-bean-scope> request </managed-bean-scope>
    <managed-property>
    <property-name>mode</property-name>
    <value>#{requestScope.mode}</value>
    </managed-property>
    <managed-property>
    <property-name>date</property-name>
    <value>#{requestScope.date}</value>
    </managed-property>
    </managed-bean>
    How should I code the following method to pass the request parameters to the next page:
    public String storeFrontLuxuryPressed() {
         setCurrentModelName("Luxury");
    //Can I do anything here to help navigation system to pass additional request parameters to
    //the carDetail.jsp page
         return "carDetail";
    Please help as I have many pages that have command_button and control leads to other pages that take request parameters to initialize and set themselves up. And I can't understand how to make the two concepts work together?
    Thanks,
    Vinay

    Thx hunangdp
    your solution of using <f:parameter> is perfect #in case# <h:command_button> is not nested inside <h:data_table> , otherwise the request parameter passed will always show the value of the 1st row , not the clicked row .
    consider the following :
    <h:data_table var="item" value="#{shoppingCartBean.shoppingItems}" >
    <h:column>
    <h:command_link value="#{item.productId}" action="product" id="productAction">
    <h:output_text value="#{item.productName}"/>
    <f:parameter name="productId" value="#{item.productId}"/>
    </h:command_link>
    </h:column>
    </h:data_table>
    in this case using the following at the back end :
    FacesContext fc = FacesContext.getCurrentInstance();
    java.util.Map requestParameter = fc.getExternalContext().getRequestParameterMap();
    String value = requestParameter.get("productId");
    will return the value of the 1st row ..
    so if, instead I consider adding an action listener which set the request attribute "productId" to the command_link value , this will work , but I have to get the value from request attribute not the request parameter ==> :
    <h:data_table var="item" value="#{shoppingCartBean.shoppingItems}"
    rowClasses="InnerTable">
    <h:column>
    <h:command_link value="#{item.productId}" action="product" id="productAction">
    <h:output_text value="#{item.productName}"/>
    <f:action_listener type="mybean.Listener"/-->
    </h:command_link>
    </h:column>
    </h:data_table>
    and mybean.listener ==> :
    String id = (String) ((UICommand) event.getComponent()).getValue();
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    request.setAttribute("productId", id);
    any comments.. ?

  • Newbie: what is the equivalent of passing request parameters?

    Hi-
    I am new to JSF. I have read many tutorials and articles. I still don't get one concept about passing parameters. Note: I don't want to store stuff in the session unless I have to.
    Let's say I have a page with a list of users. I layout the page with a panelGrid. Each row of the table has the first and last name of the user. If a user clicks on the name of a user on the user list, it should go to the user profile page. The backing bean for the user list page will be the UserListBean. It has a method called getUsers() that returns a List of User objects.
    For the View User page, I have a ViewUserBean. The ViewUserBean retrieve the entire profile for that user.
    How do I pass the user ID to the ViewUserBean? In struts, I would pass it as a request parameter (I would manually write the link URL with the userID). I know I can use the request like that in JSF, but that seems ugly. I looked at the code of the J2EE bookstore tutorial and it does a funky thing with all sorts of data stored in the session.
    What is the best way to request a page and "pass in" a userID?
    Thanks for your help.
    Adam

    I have a case on my current project very similar to your case. What you want, very simply, is an easy way to allow faces to handle URLs like http://www.domain.com/showUserDetails?userId=50
    The natural trouble is that when loading the page, there is no action to use to prefetch the User object based on the Request Parameters in JSF.
    All the solutions above either rely on the session or they are exceedingly complex. This case is actually very easy to do and is very straight forward using Managed Properties and a Request Scope bean...
    Here is the rather straight forward solution I used...
    First, make a "ShowUserDetailsBean" which represents the "logic" for this page.
    public class ShowUserDetailsBean
        /** Will point to the actual user service after dependency injection*/
        private UserService userService;
        /** Will hold the userId from the HTTP Request Parameters*/
        private String userId;
        /** Will hold a lazy loaded copy of the User object matching userId*/
        private User user;
        public void setUserService(UserService userService) {
            this.userService = userService;  //dependecy injection
        public void setUserId(String userId) {
           this.userId = userId;  //dependency injection
        /** Lazy loads the User object matching the UserId */
        public User getUser() {
            //Trap the case where the URL has no userId
            if (userId == null) return null;
            if (user == null) {
                user = userService.getUser(userId);  //Lazy Load
            return user;
    }Next, configure the managed properties in faces-config.xml
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
      <managed-bean>
        <managed-bean-name>userService</managed-bean-name>
        <managed-bean-class>foo.UserServiceImpl</managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
      </managed-bean>
      <managed-bean>
        <managed-bean-name>showUserDetails</managed-bean-name>
        <managed-bean-class>foo.ShowUserDetailsBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
          <property-name>userService</property-name>
          <property-class>foo.UserService</property-class>
          <value>#{userService}</value>
        </managed-property>
        <managed-property>
          <property-name>userId</property-name>
          <property-class>java.lang.String</property-class>
          <value>#{param.userId}</value>
        </managed-property>
      </managed-bean>Finally, you just make your webpage as you normally would...
    <h:outputText value="#{showUserDetails.user.userId}"/>
    <h:outputText value="#{showUserDetails.user.firstName}"/>
    <h:outputText value="#{showUserDetails.user.lastName}"/>
    Now you're ready to test, so you visit the page
    http://www.domain.com/showUserDetails?userId=50
    And your user details with userId=50 appears!
    It's just that simple!
    Regards,
    Doug
    Caveat: I haven't added any sample logic to handle cases where you visit:
    http://www.domain.com/showUserDetails
    without specifying a userId. I suggest you add some basic logic to your page to handle this case more gracefully.

  • Generate PDF using Managed Bean with custom HTTP headers

    Background
    Generate a report in various formats (e.g., PDF, delimited, Excel, HTML, etc.) using JDeveloper 11g Release 2 (11.1.2.3.0) upon clicking an af:commandButton. See also the StackOverflow version of this question:
    http://stackoverflow.com/q/13654625/59087
    Problem
    HTTP headers are being sent twice: once by the framework and once by a bean.
    Source Code
    The source code includes:
    - Button Action
    - Managed Bean
    - Task Flow
    Button Action
    The button action:
    <af:commandButton text="Report" id="submitReport" action="Execute" />
    Managed Bean
    The Managed Bean is fairly complex. The code to `responseComplete` is getting called, however it does not seem to be called sufficiently early to prevent the application framework from writing the HTTP headers.
    HTTP Response Header Override
    * Sets the HTTP headers required to indicate to the browser that the
    * report is to be downloaded (rather than displayed in the current
    * window).
    protected void setDownloadHeaders() {
    HttpServletResponse response = getServletResponse();
    response.setHeader( "Content-Description", getContentDescription() );
    response.setHeader( "Content-Disposition", "attachment, filename="
    + getFilename() );
    response.setHeader( "Content-Type", getContentType() );
    response.setHeader( "Content-Transfer-Encoding",
    getContentTransferEncoding() );
    Issue Response Complete
    The bean indirectly tells the framework that the response is handled (by the bean):
    getFacesContext().responseComplete();
    Bean Run and Configure
    public void run() {
    try {
    Report report = getReport();
    configure(report.getParameters());
    report.run();
    } catch (Exception e) {
    e.printStackTrace();
    private void configure(Parameters p) {
    p.put(ReportImpl.SYSTEM_REPORT_PROTOCOL, "http");
    p.put(ReportImpl.SYSTEM_REPORT_HOST, "localhost");
    p.put(ReportImpl.SYSTEM_REPORT_PORT, "7002");
    p.put(ReportImpl.SYSTEM_REPORT_PATH, "/reports/rwservlet");
    p.put(Parameters.PARAM_REPORT_FORMAT, "pdf");
    p.put("report_cmdkey", getReportName());
    p.put("report_ORACLE_1", getReportDestinationType());
    p.put("report_ORACLE_2", getReportDestinationFormat());
    Task Flow
    The Task Flow calls Execute, which refers to the bean's `run()` method:
    entry -> main -> Execute -> ReportBeanRun
    Where:
    <method-call id="ReportBeanRun">
    <description>Executes a report</description>
    <display-name>Execute Report</display-name>
    <method>#{reportBean.run}</method>
    <outcome>
    <fixed-outcome>success</fixed-outcome>
    </outcome>
    </method-call>
    The bean is assigned to the `request` scope, with a few managed properties:
    <control-flow-rule id="__3">
    <from-activity-id>main</from-activity-id>
    <control-flow-case id="ExecuteReport">
    <from-outcome>Execute</from-outcome>
    <to-activity-id>ReportBeanRun</to-activity-id>
    </control-flow-case>
    </control-flow-rule>
    <managed-bean id="ReportBean">
    <description>Executes a report</description>
    <display-name>ReportBean</display-name>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    The `<fixed-outcome>success</fixed-outcome>` strikes me as incorrect -- I don't want the method call to return to another task.
    Restrictions
    The report server receives requests from the web server exclusively. The report server URL cannot be used by browsers to download directly, for security reasons.
    Error Messages
    The error message that is generated:
    Duplicate headers received from server
    Error 349 (net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION): Multiple distinct Content-Disposition headers received. This is disallowed to protect against HTTP response splitting attacks.Nevertheless, the report is being generated. Preventing the framework from writing the HTTP headers would resolve this issue.
    Question
    How can you set the HTTP headers in ADF while using a Task Flow to generate a PDF by calling a managed bean?
    Ideas
    Some additional ideas:
    - Override the Page Lifecycle Phase Listener (`ADFPhaseListener` + `PageLifecycle`)
    - Develop a custom Servlet on the web server
    Related Links
    - http://www.oracle.com/technetwork/middleware/bi-publisher/adf-bip-ucm-integration-179699.pdf
    - http://www.slideshare.net/lucbors/reports-no-notes#btnNext
    - http://www.techartifact.com/blogs/2012/03/calling-oracle-report-from-adf-applications.html?goback=%2Egde_4212375_member_102062735
    - http://docs.oracle.com/cd/E29049_01/web.1112/e16182/adf_lifecycle.htm#CIABEJFB
    Thank you!

    The problem was that the HTTP headers were in fact being written twice:
    1. The report server was returning HTTP response headers.
    2. The bean was including its own HTTP response headers (as shown in the question).
    3. The bean was copying the entire contents of the report server response, including the headers, into the output stream.
    Firefox ignored the duplicate header errors, but Google Chrome did not.

  • Urgent - can't set managed bean value using a form, getting null

    I have a form with a bean -- unbelievably, I can't get the values entered into the form by the user to get stored into the bean. Everything is null... I've looked at a zillion examples, posts and compared etc...yet still can't see what is missing.
    Here's part of a trace :
    [cc]Dec-31 01:25:02 ApplicationImpl - Created bean resourceBean successfully
    [cc]Dec-31 01:25:02 ApplicationImpl - Storing resourceBean in scope request
    [cc]Dec-31 01:25:02 VariableResolverImpl - resolveVariable: Resolved variable:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - getValue Result:id=null name=null
    [cc]Dec-31 01:25:02 ValueBindingImpl - -->Returning id=null name=null
    If you have any ideas, please let me know--it seems just as I solve one JSF issue, I run into another on unexpectedly simple things.
    Here's the ResourceBean.java, the bean-config.xml and my jsp.
    package com.intalio.qa.tcm.view.beans;
    import java.util.Map;
    import javax.faces.context.FacesContext;
    import javax.faces.model.SelectItem;
    import org.apache.log4j.Logger;
    import com.intalio.qa.exceptions.DuplicateIdException;
    import com.intalio.qa.tcm.model.Resource;
    import com.intalio.qa.tcm.view.builders.ResourceBuilder;
    import com.intalio.qa.tcm.view.util.FacesUtils;
    * Resource backing bean.
    public class ResourceBean extends RootBean {
         * Class logger
         public static final Logger LOG =
              Logger.getLogger(ResourceBean.class);
    * The Resource id
         private String id = null;
         * The Resource name
         private String name = null;
    * Description
    private String description= null;
         * the resource type id associated with the Resource
         private String resourceTypeId= null;
         private static SelectItem[] resourceTypeIds = new SelectItem[] {
              new SelectItem("External Software"),
              new SelectItem("Hardware"),
              new SelectItem("Intalio Product Software"),
              new SelectItem("Machine - Dual CPU"),
              new SelectItem("Machine - CPU Single"),
              new SelectItem("Memory - UNIX"),
              new SelectItem("Memory - Windows") };
    * @return Returns the resourceTypeIds.
    public SelectItem[] getResourceTypeIds() {
    return resourceTypeIds;
    * @param resourceTypeIds The resourceTypeIds to set.
    public void setResourceTypeIds(SelectItem[] typeIds) {
    resourceTypeIds = typeIds;
         * Default constructor.
         public ResourceBean() {
    super();
    init();
         * Initializes ResourceBean.
         * @see RootBean#init()
         protected void init() {
         /*True, but I'd strongly recommend instead using:
    FacesContext fContext = FacesContext.getCurrentInstance();
    Map requestParams = fContext.getExternalContext().getRequestParameterMap();
    String companyId = (String) requestParams.get("companyID");
    The getRequest(), getSession(), and getContext() methods of ExternalContext should only be used as a last resort.*/
         * Backing bean action to update Resource.
         * @return the navigation result
         public String updateAction() {
              LOG.info("updateAction is invoked");
              try {
                   Resource Resource = ResourceBuilder.createResource(this);
                   LOG.info("ResourceId = " + Resource.getId());
              //     viewServicesManager.getResourceService().updateResource(Resource);
              } catch (Exception e) {
                   String msg = "Could not update Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error.");
                   return ActionResult.FAILURE;
              LOG.info("Resource with id of " + id + " was updated successfully.");
              return ActionResult.SUCCESS;
         * Backing bean action to create a new Resource.
         * @return the navigation result
         public String addAction() {
              try {
                   Resource resource = ResourceBuilder.createResource(this);
    LOG.info("resource created: " + resource.getName() + " with typeId = " + resource.getResourceTypeId());
                   viewServicesManager.getResourceService().saveResource(resource);
              } catch (DuplicateIdException de) {
                   String msg = "This id already exists";
                   LOG.info(msg);
                   FacesUtils.addErrorMessage(msg);
                   return ActionResult.RETRY;
              } catch (Exception e) {
                   String msg = "Could not save Resource";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(msg + ": Internal Error");
                   return ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was created successfully.";
              LOG.info(msg);
              return ActionResult.SUCCESS;
         * Backing bean action to delete Resource.
         * @return the navigation result
         public String deleteAction() {
              LOG.info("deleteAction is invoked");
              try {
         //          Resource Resource = ResourceBuilder.createResource(this);
         //          viewServicesManager.getResourceService().deleteResource(Resource);
                   //remove the ResourceList inside the cache
    //               FacesUtils.resetManagedBean(BeanNames.RESOURCE_LIST_BEAN);
              } catch (Exception e) {
                   String msg = "Could not delete Resource. ";
                   LOG.error(msg, e);
                   FacesUtils.addErrorMessage(null, msg + "Internal Error.");
                   return ActionResult.FAILURE;
              String msg = "Resource with id of " + id + " was deleted successfully.";
              LOG.info(msg);
              FacesUtils.addInfoMessage(msg);
              return ActionResult.SUCCESS;
         public String getId() {
              return id;
         * Invoked by the JSF managed bean facility.
         * <p>
         * The id is from the request parameter.
         * If the id is not null, by using the id as the key,
         * the Resource bean is initialized.
         * @param newQueryId the query id from request parameter
         public void setId(String newId) {
              LOG.info("setId " + newId);
              id = newId;
         public String getName() {
              return name;
         public void setName(String newName) {
              name = newName;
         public String getDescription() {
              return description;
         public void setDescription(String newDescription) {
              description = newDescription;
         public String getResourceTypeId() {
              return resourceTypeId;
         public void setResourceTypeId(String newResourceTypeId) {
              resourceTypeId = newResourceTypeId;
         public String toString() {
              return "id=" + id + " name=" + name;
         <!-- view -->
         <managed-bean>
              <description>
                   Managed bean
              </description>
              <managed-bean-name>applicationBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ApplicationBean
              </managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
              </managed-bean>
         <managed-bean>
              <description>
                   View service manager impl for business services
              </description>
              <managed-bean-name>viewServicesManagerBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ViewServicesManagerBean</managed-bean-class>
              <managed-bean-scope>application</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <description>
                   Backing bean that contains product information.
              </description>
              <managed-bean-name>resourceBean</managed-bean-name>
              <managed-bean-class>
                   com.intalio.qa.tcm.view.beans.ResourceBean
              </managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
              <managed-property>
                   <property-name>viewServicesManager</property-name>
                   <value>#{viewServicesManagerBean}</value>
              </managed-property>
         </managed-bean>
    </faces-config>
    <f:view>
         <h:form id="createResourceForm" target="dataFrame">
              <h:outputText value="#{applicationBean.dummyVariable}" rendered="true" />
              <div align="center">
              <head>
              <link href="../../css/stylesheet.css" rel="stylesheet" type="text/css">
              <FONT color="#191970" size="4" face="Arial">Resources View</FONT>
              </head>
              <table style="margin-top: 2%" width="35%" cellpadding="10">
                   <div align="left">
                   <FONT color="#191970" size="3" face="Arial">Update Resources </FONT>
                   </div>
                   <tr>
                        <td align="center" valign="top" align="center" style="" bgcolor="white" />
                        <table>
                             <tbody>
                                  <tr>
                                       <td align="left" styleClass="header" width="100" />
                                       <td align="left" width="450" />
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Id" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.id}" id="id"/> <h:message for="id" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100"><h:outputText value="Name" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.name}" id="name" /> <h:message for="name" styleClass="errorMessage" /></td>
                                  </tr>
                                  <tr>
                                       <!--td align="right" width="100" valign="bottom"><h:outputText value="Type" /></td>
                                       <td align="left" width="550"><h:selectOneMenu>
                                            <f:selectItems value="#{resourceBean.resourceTypeIds}" />
                                       </h:selectOneMenu> <h:outputText value="#{resourceBean.resourceTypeId}" id="dresourceTypeId" /> <h:message for="resourceTypeId" styleClass="errorMessage" />
                                       </td>
                                  </tr>
                                  <tr>
                                       <td align="right" width="100" valign="bottom"><h:outputText value="Description" /></td>
                                       <td align="left" width="450"><h:inputText value="#{resourceBean.description}" id="description" size="96" /> <h:message for="description" styleClass="errorMessage" /></td>
                                  </tr>
                             </tbody>
                        </table>
         </h:form>
         </td>
         <!-- END DATA FORM -->
         <!-- BEGIN COMMANDS -->
         <td width="30%" align="left" valign="top"><h:form id="buttonCommandsForm">
              <h:panelGroup id="buttons">
                   <h:panelGrid columns="1" cellspacing="1" cellpadding="2" border="0" bgcolor="white">
                        <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
                        </h:commandButton>
                        <h:commandButton id="deleteCB" value="Delete" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.deleteAction}">
                        </h:commandButton>
                        <h:commandButton id="spaceFillerButton" style="height:21px; width:51px;font-size:8pt;background-color: #ffffff;color: #ffffff;border: 0px;">
                        </h:commandButton>
                        <h:commandButton id="saveCB" value="Save" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.saveAction}">
                        </h:commandButton>
                        <h:commandButton id="updateCB" value="Update" style="height:21px; width:51px;font-size:8pt" action="#{resourceBean.updateAction}">
                        </h:commandButton>
                   </h:panelGrid>
              </h:panelGroup>
         </h:form> <!-- end buttons --></td>
         </tr>
         </table>
         <HR align="center" size="2" width="60%" />
         <!-- data table -->
         </div>
    </f:view>
    THANKS.
    -L

    I solved this.
    Since I was testing the action code only, I didn't define a navigation entry corresponding to the action string returned for this button:
    <h:commandButton value="Add" style="height:21px; width:51px;font-size:8pt; font-color: black;" action="#{resourceBean.addAction}">
    </h:commandButton>After I added a nav definition, it worked. I don't know why at this point. I suspect a key step in the lifecycle was pre-empted...someone else can probably explain why. If I get a chance to research it after I'm done with my project, I'll update this post.
    Thanks.
    -L

  • Managed bean inheritance best practice

    Hi!
    I'm new to JSF so I would like to apologize if my question is trivial, but I haven't been able to find proper solution.
    I'm using JSF 1.2 on WAS CE. I have a page where user can search for some entities, both person and company, which share some data, but have some different properties. Both inherit from entity class, so search results are displayed in dataTable as base entity objects. Each dataTable row has commandLink which should navigate user to specific (person or company) page for editing data. For example, if user clicks on commandLink in person data row, I would like to show personEdit page with all data set to components. I understand that I can use action to set navigation to proper page, and I have done so (following action() method). I have implemented EntityBean, PersonBean and CompanyBean:
    public class EntityBean {
        protected Entity entity;
        public int getId() {
            return entity.getId();
        public void setId(int id) {
            entity.setId(id);
        public String action() {
            // Some code which defines return value for action invoking.
        public void edit(ActionEvent event) {
            // Get entity data for edit.
    public class PersonBean extends EntityBean {
        public String getFirstName() {
            return ((Person)entity).getFirstName();
    public class CompanyBean extends EntityBean {
        public String getName() {
            return ((Company)entity).getName();
    }I tried combining action with actionListener method (+edit(ActionEvent event)+ method) invoked from commandLink, but if it is invoked on mapped entityBean, I get only entity properties set on any other page which is shown after invoked action. If method is invoked on i.e. personBean (same method, not overriden), I get NullPointerException for trying to access property for base entityBean.
    How should I invoke proper data initialization for bean shown on another page?
    Thanks in advance.

    Thank you for your quick reply. Beside the code for managed bean classes, here's the rest of the code for this specific problem.
    In faces-config.xml I have the following configuration:
         <managed-bean>
              <managed-bean-name>entitySearchBean</managed-bean-name>
              <managed-bean-class>entities.EntitySearchBean</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>personBean</managed-bean-name>
              <managed-bean-class>entities.PersonBean</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>
         <managed-bean>
              <managed-bean-name>entityBean</managed-bean-name>
              <managed-bean-class>legalentities.EntityBean</managed-bean-class>
              <managed-bean-scope>request</managed-bean-scope>
         </managed-bean>On my JSP, I have a dataTable loaded with entityBean objects, and the following code for showing editPage:
         <h:column>
              <h:commandLink id="editLink" action="#{entitySearchBean.editEntity}" actionListener="#{entityBean.edit}">
                   <h:outputText value="#{bundle.edit}" />
                   <f:param id="editId" name="editId" value="#{entity.id}" />
              </h:commandLink>
         </h:column>
    </h:dataTable>So, what I'm trying to do is to call entityBean.edit which should initialize EntityBean with entity data, and it sets i.e. person data to entity field of EntityBean class. I also call editEntity method on EntitySearchBean class (bean used just for searching entities with some criteria), and pass id property of selected entity in dataTable.
    What I'm expecting is to get personEdit.jsp with loaded personBean data initialized from actionListener on searchPage.jsp. Is it possible or is there some other way to do this?

Maybe you are looking for

  • Alignment Guides In Pages 5

    What happened to Alignment Guides? #APPLE are you being serious?! The new Pages 5 is a joke.

  • Can't see artwork

    Hi I've been sent a PSD which opens fine (although font's not available) but I can't see the artwork, all the layers are there, visible and selectable but the artwork is all grayed out on the artboard. Wondering if this is a glitch?

  • Screen-resolution resize

    Hi, Since I have Leopard my screen-resolution always resize after my pc is coming back from the screensaver or hibernate-mode. Also when I afterwards go to the screen properties my default screen-resolution (1440x900) is not listed and I have to dete

  • Backsaving Indesign File

    Hi all, I just wanted to as a question before I talk to my client. I've been working on a 400 page product catalog for a couple months.  We're now done and my client wants a final disk for their file.  I know they have Indesign on the pc but I'm not

  • Export Settings in LR3

    What are the smallest eports settings for printing up to 8x12? Does resizing to 2400px on the Long edge at 200ppi make sense? I would like the smallest printable file possible. I am emailing thousands of Santa photos to hundreds of people and sending