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 9088377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:53:48+00:00 2026-06-16T21:53:48+00:00

I’m trying to get na few parameters (now it’s two, but on the other

  • 0

I’m trying to get na few parameters (now it’s two, but on the other xhtml probably I’ll need more).

On page index.html I have a link, to page Threads.xhtml, with parameters user_id and section_id:

<h:dataTable value="#{Sections.sections}" var="Section">
    <h:column>
        <h:form>
            <h:link value="#{Section.section_label}" outcome="Threads">
                <f:param name="user_id" value="#{LoginIn.user_id}"/>
                <f:param name="section_id" value="#{Section.section_id}"/>
            </h:link>
        </h:form>
    </h:column>
</h:dataTable>

When I click into on of the links, it goes to for ex.:

Project/faces/Threads.xhtml?user_id=5&section_id=2

So it’s good :).

Now, on page Threads.xhtml I have a link (one link, not dataTable, as on index.xhtml – to create new section), to page NewThread.xhtml, with parameters user_id and section_id:

<h:form>
    <h:link value="#{msg.create_new_thread}" outcome="NewThread">
        <f:param name="user_id" value="#{param.user_id}"/>
        <f:param name="section_id" value="#{param.section_id}"/>
    </h:link>
</h:form>

When I click into on of the links, it goes to, for ex..:

Project/faces/NewThread.xhtml?user_id=5&section_id=2

So it’s also nice :).

Now, I check on NewThread.xhtml page values of user_id and section_id, by:

<h:outputText value="User_id: #{param.user_id}"/><br/>
<h:outputText value="Section_id: #{param.section_id}"/><br/>

And I see on page values:

User_id: 5
Section_id: 2

So ok :). But now, when I’m trying to get these values in Java code NewThread.java, they returns only null:

FacesContext facesContext = FacesContext.getCurrentInstance();
String user_id = (String) facesContext.getExternalContext().getRequestParameterMap().get("user_id");
String section_id= (String) facesContext.getExternalContext().getRequestParameterMap().get("section_id");
//For test:
System.out.println("User_id: " + user_id);
System.out.println("Section_id: " + section_id);

And in console i’ve got:

User_id: null
Section_id: null

I’ve also try toString() method, but it didn’t help.

Going back to the index.xhtml, when I click on the link to one of the section, ex. second section (by any user, ex. user_id=5), it goes to Threads.xhtml:

Project/faces/Threads.xhtml?user_id=5&section_id=2

And on Threads.xhtml I’ve got list of Threads of second section (but this part of xhtml code is irrelevant):

<h:dataTable value="#{Threads.threads}" var="Thread">
    <h:column>
        <h:link value="#{Thread.thread_label}" outcome="Threads">
            <f:param name="thread_id" value="#{Thread.thread_id}"/>
        </h:link>
    </h:column>
</h:dataTable>

And on Java code of Threads.java, I’ve got:

FacesContext facesContext = FacesContext.getCurrentInstance();
String section_id = (String) facesContext.getExternalContext().getRequestParameterMap().get("section_id");
System.out.println("Section_id: " + section_id);

And in console i’ve got:

Section_id: 2

So WTF? Once it works, but another time it won’t.

EDIT:

Sorry, I forgot. I access into NewThread.java, by commandButton in NewThread.xhtml:

<h:commandButton value="#{msg.add_thread}" action="#{NewThread.AddThread}"/>

and it calls AddThread method in NewThread.java; and in try (of try-catch) of AddThread method, there I’m trying to get parameters.

I’ve also already add into faces-config.xml:

<managed-bean>
    <managed-bean-name>Threads</managed-bean-name>
    <managed-bean-class>forum.Threads</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<managed-bean>
    <managed-bean-name>NewThread</managed-bean-name>
    <managed-bean-class>forum.NewThread</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
</managed-bean>
  • 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-16T21:53:49+00:00Added an answer on June 16, 2026 at 9:53 pm

    When you click an h:commandButton, a new request is made. The problem is that the parameters are not being passed to this request.

    So, if you want your request scoped bean NewThread to get the data from the request parameters, you have to include the parameters in the request made from the h:commandButton too. Try this:

    <h:commandButton value="#{msg.add_thread}" action="#{NewThread.AddThread}">
        <f:param name="user_id" value="#{param.user_id}"/>
        <f:param name="section_id" value="#{param.section_id}"/>
    </h:commandButton>
    

    As you are using JSF 2, you may find useful to use f:metadata with f:viewParam together with the includeViewParameters=true trick for navigating between pages, check out these questions:

    • What can <f:metadata>, <f:viewParam> and <f:viewAction> be used for?
    • Handling view parameters in JSF after post
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Basically, what I'm trying to create is a page of div tags, each has
In my XML file chapters tag has more chapter tag.i need to display chapters
I need to clean up various Word 'smart' characters in user input, including but
I upgraded downgraded to rails 2.3.17 due to the security bugs, but now I
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.