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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:52:14+00:00 2026-05-31T18:52:14+00:00

I am passing three feields but only the first one is being passed even

  • 0

I am passing three feields but only the first one is being passed even though the built URL shows correct values:

TestBean1:

@ManagedBean
@RequestScoped
public class TestBean1 implements Serializable  {


private String field1;
private String field2;
private String field3;

// Constructor
public TestBean1() {

}

public void handleRequest() throws IOException {

    setField1("1 Julie");
    setField2("2 Kyle");
    setField3("3 Bob");

    String field1 = URLEncoder.encode(this.field1, "UTF-8");
    String field2 = URLEncoder.encode(this.field2, "UTF-8");
    String field3 = URLEncoder.encode(this.field3, "UTF-8");     

    String url = "Bean2.jsf?field1=" + field1 + "&field2=" + field2
                + "&field3=" + field3;

      FacesContext.getCurrentInstance().getExternalContext().redirect(url); 

}

// Getter and Setters
public String getField1() {
    return field1;
}

public void setField1(String field1) {
    this.field1 = field1;
}
public String getField2() {
    return field2;
}

public void setField2(String field2) {
    this.field2 = field2;
}

public String getField3() {
    return field3;
}

public void setField3(String field3) {
    this.field3 = field3;
}

  }

Bean1.jsf

  <ui:composition 

 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:p="http://primefaces.org/ui"
 template="/templates/template.xhtml">


<ui:define name="title">
    Bean 1
</ui:define>

  <ui:define name="content">

  <h:body>

<h:form>
  <table>
    <tr>        <td>Bean 1 </td>            </tr>
    <tr>        <td> </td>              </tr>
    <tr>        <td> </td>          </tr>
    <tr>        <td><h:commandLink value="Submit" action="#
                                    {testBean1.handleRequest}" /> </td>     </tr>
</table>

</h:form>   
  </h:body>
  </ui:define>  
  </ui:composition> 

Bean2.jsf

  <ui:composition 

 xmlns="http://www.w3.org/1999/xhtml"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:ui="http://java.sun.com/jsf/facelets"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:p="http://primefaces.org/ui"
 template="/templates/template.xhtml">

 <f:metadata>
 <f:viewParam name="field1" value="#{testBean2.field1}"/>
 <f:viewParam name="field2" value="#{testBean2.field2}"/>
 <f:viewParam name="field3" value="#{testBean2.field3}"/>
 </f:metadata>

<ui:define name="title">
    Bean 2
</ui:define>

 <ui:define name="content">

 <h:body>

<h:form>

<table>
    <tr>    <td>Bean 2 </td> </tr>
    <tr>    <td><h:inputText id="Input" value="#{testBean2.myInput}"/>  </td> /tr>      <tr>    <td> </td>  </tr>
    <tr>    <td> <h:outputText value="#{testBean2.field1}"    />  </td>     </tr>
    <tr>    <td> <h:outputText value="#{testBean2.field2}" />    </td>      </tr>
    <tr>    <td> <h:outputText value="#{testBean2.field3}" />    </td>      </tr>
    <tr>    <td> <h:commandLink value="Click" 
                       action="#{testBean2.handleRequest}" /> </td> </tr>

     </table>

</h:form>   
   </h:body>
   </ui:define> 
   </ui:composition>

TestBean2

     @ManagedBean
     @ViewScoped
     public class TestBean2  implements Serializable  {

private static final long serialVersionUID = -9L;

private String field1;
private String field2;
private String field3;

private String myInput = "Hello";


// Constructor
public TestBean2 () {
}

public void handleRequest() {

    System.out.println("field1 " + field1  + "  field2 " + field2 + "  field3 " + 
                    field3);

}


// Getter and Setters

    public String getField1() {
        return field1;
    }

    public void setField1(String field1) {
        this.field1 = field1;
    }
    public String getField2() {
        return field2;
    }

    public void setField2(String field2) {
        this.field2 = field2;
    }

    public String getField3() {
        return field3;
    }

    public void setField3(String field3) {
        this.field3 = field3;
    }

public String getMyInput() {
    return myInput;
}

public void setMyInput(String myInput) {
    this.myInput = myInput;
}

   }

When I run this I get only value for field1.

Thanks,

  • 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-05-31T18:52:15+00:00Added an answer on May 31, 2026 at 6:52 pm

    In template clients, the <f:metadata> needs to go inside an <ui:define>, otherwise the behaviour is undetermined. See also the documentation of the <f:metadata> tag for an example.

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

Sidebar

Related Questions

Is there a benefit to passing a string in your url patters vs a
Is there a way to recieve the complete nameserver set by passing just one
being new to c# I've run into this 'conundrum' when passing around a SqlDataReader
Is there a graceful way to handle passing a list of ids as a
Is there a performance benefit by passing ints by reference rather than by value
Is there a way to call send / recv passing in a vector ?
Is there any benefit (or conversely, cost) to passing a parameter by const value
Is there a way to start an instance of eclipse, passing it some sort
In relation to my last question ( Is there an easier way of passing
StructureMap doesn't like passing in Nullable types as constructor arguments. Is there a reason

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.