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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:10:32+00:00 2026-06-01T20:10:32+00:00

Possibly I’m using forms incorrectly. The idea is that detail.content displays some HTML, and

  • 0

Possibly I’m using forms incorrectly. The idea is that detail.content displays some HTML, and this portion works fine. The form is supposed to allow multiple (one-to-many notes to be entered and displayed on the right.

While the default note is displayed, more notes are not. How do I link the note bean to the detail bean? I was thinking of a String “id” and passing that from one bean to another.

This is similar to the idea of passing params from one view.xhtml to another, except that it’s all on one page. I would like to keep the beans distinct. Ultimately, I would like to do this with EJB’s, and so want to keep that option open, while not using EJB’s yet.

view, detail.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="./complexTemplate.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="top">
        <h:form>
            <h:outputLink id="back" value="detail.xhtml">
                <f:metadata>
                    <f:viewParam name="id" value="#{detail.id}"  />
                </f:metadata>
                <f:param name="id" value="#{detail.back()}" />
                <h:outputText value="back" />
            </h:outputLink>
        </h:form>
        <h:form>
            <h:outputLink id="forward" value="detail.xhtml">
                <f:metadata>
                    <f:viewParam name="id" value="#{detail.id}"  />
                </f:metadata>
                <f:param name="id" value="#{detail.forward()}" />
                <h:outputText value="forward" />
            </h:outputLink>
        </h:form>
    </ui:define>
    <ui:define name="content">
        <h:outputText escape="false" value="#{detail.content}"></h:outputText>
    </ui:define>
    <ui:define name="right">
        <p>#{notes.note.id}</p>
        <p>#{notes.note.comment}</p>
        <h:form>
            <h:inputText value="#{notes.note.comment}" />
            <h:commandButton value="add note"
                             action="#{notes.commentAction()}"/>
        </h:form>
    </ui:define>
</ui:composition>

bean, Notes.java:

package net.bounceme.dur.nntp;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.Dependent;
import javax.inject.Named;

@Named
@Dependent
public class Notes {

    private static final long serialVersionUID = 1L;
    private static final Logger logger = Logger.getLogger(Notes.class.getName());
    private static final Level level = Level.INFO;
    private Note note = new Note();

    public Notes() {
        logger.log(level, "Notes..");
    }

    public Note getNote() {
        return note;
    }

    private void setNote(Note note) {
        this.note = note;
    }

    public void commentAction() {
        logger.log(level, "Notes.newNote..");        note.setId("messageIdGoesHere");
        note.setComment("hmmm");
    }
}

The other bean, Details, works fine. However, I’m not sure how to integrate two beans onto one page so that the two beans are aware of each other.

  • 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-01T20:10:33+00:00Added an answer on June 1, 2026 at 8:10 pm

    Use @Inject.

    @Named
    public class Notes {
    
        @Inject
        private Detail detail;
    
    }
    

    It’ll be available in the Notes instance during the lifetime beyond the @PostConstruct method. The other way round can also. It’s not entirely clear what the parent-child relationship is in your particular case.


    Unrelated to the concrete problem, you’ve there some odd view markup. Only one <f:metadata> in top of definition is sufficient. Also, #{detail.back()} as a value expression is odd. You should have a getBack() method and reference it as #{detail.back}. The same for forward(). Also, EJBs have nothing to do with this all. Whether you plan to use EJBs or not is irrelevant to this particular issue. I’d suggest learning JSF by a decent book/tutorial, not by cobbling some loose snippets together while not understanding the complete picture.

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

Sidebar

Related Questions

Possibly this is related to Using a plugin generated with Firebreath in a Firefox
I have page that possibly calls this line. jQuery.ajaxSetup({async:false}) In another function I would
Possibly this should be on Superuser, but I'm using it in code so thought
Possibly a silly question, but I'm having no luck finding an answer. Using Visual
a possibly simple problem, but weird why I have no idea how to do
What could possibly cause this weird python behaviour? Python 2.6.2 (r262:71600, May 31 2009,
This could quite possibly be the dumbest question ever asked. Our client wants us
I can't possibly be the first person to do this, it seems like it
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
what possibly i am doing wrong or what i can do with this code

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.