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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:08:23+00:00 2026-06-01T11:08:23+00:00

So, I have a backing bean, Foo, and a template with a client, request

  • 0

So, I have a backing bean, Foo, and a template with a client, request and response. the clients are redundant, I want just one client.

Clients:

thufir@dur:~$ 
thufir@dur:~$ cat NetBeansProjects/NNTPjsf/web/foo/request.xhtml 
<?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="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html">

    <ui:define name="left">

        <h:form>
            <h:inputText size="2" maxlength="50" value="#{foo.bar}" />
            <h:commandButton id="submit" value="submit" action="response" />
        </h:form>
    </ui:define>

    <ui:define name="content">
        <h:outputText value="#{foo.bar}"></h:outputText>
    </ui:define>

</ui:composition>
thufir@dur:~$ 
thufir@dur:~$ cat NetBeansProjects/NNTPjsf/web/foo/response.xhtml 
<?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="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html">

    <ui:define name="left">

        <h:form>
            <h:inputText size="2" maxlength="50" value="#{foo.bar}" />
            <h:commandButton id="submit" value="submit" action="response" />
        </h:form>
    </ui:define>

    <ui:define name="content">
        <h:outputText value="#{foo.bar}"></h:outputText>
    </ui:define>

</ui:composition>
thufir@dur:~$ 

Which I think is ok, in and of itself.

Backing bean:

package guessNumber;

import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.faces.context.FacesContext;
import javax.inject.Named;
import javax.servlet.http.HttpSession;

@Named
@SessionScoped
public class Foo implements Serializable {

    private String bar = "bar";
    private String response = "response";

    public Foo() {
    }

    /**
     * @return the bar
     */
    public String getBar() {
        return bar;
    }

    /**
     * @param bar the bar to set
     */
    public void setBar(String bar) {
        this.bar = bar;
    }

    /**
     * @return the response
     */
    public String getResponse() {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
        session.invalidate();
        response = "hmm";
        return response;
    }

    /**
     * @param response the response to set
     */
    public void setResponse(String response) {
        this.response = response;
    }
}

What I would like is just a single client, request_response or something. So that the text input form stays on the left and the result on the right. That’s done with composition tags? Or, a third “general client” which has two sub-clients?

  • 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-01T11:08:23+00:00Added an answer on June 1, 2026 at 11:08 am

    You need to change your commandButton on the request page to call an action method in the backing bean:

    <h:commandButton id="submit" value="submit" action="#{foo.doAction}" />
    

    In the action method set the response:

    public String doAction() {
      response = "hmm";
      return "response";
    }
    

    The return value of the action method navigates to the page /response.xhtml.

    But you don’t need two pages. You can return null from the action method to reload the current (request) page:

    public String doAction() {
      response = "hmm";
      return null;
    }
    

    Then the changed values for bar and response can be shown on the right side:

    <ui:define name="content">
      <h:outputText value="#{foo.bar}"></h:outputText>
      <h:outputText value="#{foo.response}"></h:outputText>
    </ui:define>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two drop downs on a page whose backing bean is Request Scoped.
I am trying to get a generic tree backing-bean to work. I have one
Say I have a JSF backing bean, request scope, that has a List as
I have a Collection of model objects in my backing bean, and I want
I have Facelet component and I have backing bean for it. When I include
I have a problem with selectInputDate: I have a backing bean which I am
I have a web application with a backing bean which has the context of
I have a search form tied to a backing bean that contains 4 input
I have a simple JSF+RichFaces form with some fields and obviously a backing bean
I want to know how to call a method in the backing bean once

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.