Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7826967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:38:37+00:00 2026-06-02T09:38:37+00:00

I have managedBean for fileUpload , once file is uploaded then i need to

  • 0

I have managedBean for fileUpload, once file is uploaded then i need to call different parsers based on what value is selected from the parser dropdown and then in parser am creating object of DetailsClass where am calling getDetails method for that particular class, thing to note here is that neither parserClass nor DetailsClass is registered in faces-config.xml, my question here is

  • If i want to maintain session information from FileUpload class to Parser class to DetailsClass then I should be defining it in faces-config.xml but how should parser class and DetailsClass be defined, should it be defined as managedBean or like something else?

Here is the code:

In my managedBean class i have two function, fileUpload and callParser as shown:

 public void uploadFile(FileEntryEvent event)
{
    FacesContext ctx = FacesContext.getCurrentInstance();
    //Setting getSession to false, container will not create new session if session is not present and return null
    HttpSession session = (HttpSession) ctx.getExternalContext().getSession(false);
    setSession(session);

    resultBean = new ResultBean();
    FileEntry fileEntry = (FileEntry) event.getSource();
    FileEntryResults results = fileEntry.getResults();
    FileEntry fe = (FileEntry) event.getComponent();

    FacesMessage msg = new FacesMessage();
    for (FileEntryResults.FileInfo fileInfo : results.getFiles())
    {
        if (fileInfo.isSaved())
        {
            File file = fileInfo.getFile();
            String filePath = file.getAbsolutePath();
            callParser(selectedItem, filePath);
        }
        resultBeanList.add(resultBean);
    }
}

private void callParser(String parserType, String filePath)
{
    if ("Delta".equals(parserType))
    {
        PositionParserDelta deltaParser = new PositionParserDelta();
        deltaParser.getQuotes(filePath);
    }
    else if ("Gamma".equals(parserType))
    {
        PositionParserGamma gammaParser = new PositionParserGamma();
        gammaParser.getQuotes(filePath);
    }
}

Now, let say we consider Delta Parser, so in that class I have something like:

public class PositionParserDelta extends Base
{
    List<String[]> dataList = new ArrayList<String[]>();
    ContractManager contractManager = new ContractManager();

    public PositionParserDelta()
    {
    }

    public void getQuotes(String fileName)
    {
        try
        {
            Map<String, ContractSeries> gsLookup = contractManager.getContractsMap(ContractManager.VendorQuotes.KRT);
            CSVReader reader = new CSVReader(new FileReader(fileName), '\t');
            String[] header = reader.readNext();
            dataList = reader.readAll();
            List<Trade> tradeBeanList = new ArrayList<Trade>();
            for (String[] data : dataList)
            {
                //Some Business Logic
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

My contractManager Class looks like

    public class ContractManager extends Base
    {
        private List<Series> List = new ArrayList<Series>();
        private ContractSeries[] SeriesList = new Series[3];
        private ListingOps listingOps;

//This line throws error as faces class not found and it makes sense because am not registering this with faces-config.xml
        HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);

        public List<ContractSeries> getContracts(long orgId, HttpSession session)
        {
            log.info("Inside getContracts method call");
            if (false)
            {
                //Some Logic
            }
            else
            {
                try
                {
                    //Set session and get initialContext to retrieve contractSeries data from ejb calls
                    log.info("Trying to get allContractSeries data from listingOpsBean");
                    Series[] allSeries = deltaOps.findAllSeries(true);
                    Collections.addAll(contractList, allContractSeries);
                }
                catch (Exception ex)
                {

                }
            }
            return contractList;
        }

        public Map<String, ContractSeries> getContractsMap(VendorQuotes vendorQuotes)
        { //Some Logic
    }

But in faces-config.xml file,

 <managed-bean>
        <managed-bean-name>fileUpload</managed-bean-name>
        <managed-bean-class>trade.UploadBlotterBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

So basically my question is,

if suppose am calling other classes from managedBean then how should
they be defined in faces-config.xml and since am new to JSF, is
calling other classes from managedBean and having some business
logic in those classes considered good practice?

Also i need to make sure that i maintain session that i obtain in UploadFile across Parser and ContractMapping class.

Also,

Is everything is ‘registered’ as managed-bean in faces-config ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:38:38+00:00Added an answer on June 2, 2026 at 9:38 am

    Not sure but I think every bean is registered as <managed-bean> in faces-config. On the specific role, a class plays, they can be categorized into

    1. Model Managed-Bean

    2. Backing Managed-Bean

    3. Controller Managed-Bean

    4. Support Managed-Bean

    5. Utility Managed-Bean …

    By giving them appropriate name you can distinguish them in faces-config. As per the work served by bean , set there scopes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have data loaded from DB, when click a command button: <h:commandButton value=Show article
I have the following 2 ManagedBean: @ManagedBean @ViewScoped public class MakeReservation { ... @ManagedProperty(value=#{cartManagedBean})
I have read about passing parameters from jsf page to managedbean through actionListener. Is
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
Have someone tried out DeCAL in Delphi 2009? I'm thinking about upgrading from 2007,
I have a @ViewScope ManagedBean and a @PostConstruct initialisation method. This method is called
I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean
I have a @ManagedBean in my app, with the @sessionScoped anotation. The problem is
I have a custom converter which is this : @ManagedBean @RequestScoped public class MeasureConverter
i have a repeating form like this: <ui:repeat var=blogPost value=#{blogPosts}> <h:form> <div class=full> <label

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.