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

  • Home
  • SEARCH
  • 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 7757955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:13:52+00:00 2026-06-01T13:13:52+00:00

How do I send the current javax.mail.Message which the ListDataTable is on for the

  • 0

How do I send the current javax.mail.Message which the ListDataTable is on for the particular row back to the backing bean in order to get some header information for that specific Message instance? I think the problem is that this is from within the client dataTable.

How do I make getUrl available to the ListDataTable?

I’ve tried:

<h:outputText value="#{messageBean.foo(m.header("Archived-at"))}"></h:outputText>

which returns an error of:

Element type "h:outputText" must be followed by either attribute specifications, ">" or "/>".

I think it’s something along the lines of a command link, which suggests a syntax of:

<h:commandLink action="#{bean.insert(item.id)}" value="insert" />

Which is near to what I’m doing. In my case, I just want to send the specific message back to MessageBean.getUrl(Message) yet that doesn’t work as I expect.

I’ve also tried:

/foo/client.xhtml @48,61 value="#{messageBean.url(m)}": Method url not found

So that’s clearly not the correct way to send an object from the template client to the backing bean. However, that’s the approach which I would like, to send the actual Message instance back to the bean.

the facelets 2.0 client:

<?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"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core">
    <ui:define name="content">
        <h:dataTable value="#{messageBean.model}" var="m">
            <h:column>
                <f:facet name="subject">
                    <h:outputText value="subject" />
                </f:facet>
                <h:outputText value="#{m.subject}"></h:outputText>
            </h:column>
            <h:column>
                <f:facet name="content">
                    <h:outputText value="content" />
                </f:facet>
                <h:outputText value="#{m.sentDate}"></h:outputText>
            </h:column>
            <h:column>
                <f:facet name="date">
                    <h:outputText value="date" />
                </f:facet>
                <h:outputText value="#{m.sentDate}"></h:outputText>
            </h:column>
        </h:dataTable>
    </ui:define>
</ui:composition>

the backing bean:

package net.bounceme.dur.nntp;

import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.enterprise.context.SessionScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.inject.Named;
import javax.mail.Header;
import javax.mail.Message;

@Named
@SessionScoped
public class MessageBean implements Serializable {

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

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

    public DataModel getModel() throws Exception {
        logger.log(level, "MessageBean.getModel..");
        List<Message> messages = new ArrayList<Message>();
        SingletonNNTP nntp = SingletonNNTP.INSTANCE;
        messages = nntp.getMessages();
        DataModel messagesDataModel = new ListDataModel(messages);
        return messagesDataModel;
    }

    public List<String> getStringHeaders(Message message) throws Exception {
        List<Header> headerListOfHeaders = getHeaders(message);
        List<String> stringListOfHeaders = new ArrayList<String>();
        for (Header h : headerListOfHeaders) {
            stringListOfHeaders.add(h.getName() + " " + h.getValue() + "\n");
        }
        return stringListOfHeaders;
    }

    public URL getUrl(Message message) throws Exception {
        List<Header> headers = getHeaders(message);
        URL url = new URL("http://www.google.com/");
        for (Header h : headers) {
            if ("Archived-at".equals(h.getName())) {
                String s = h.getValue();
                s = s.substring(1, s.length() - 1);
                url = new URL(s);
            }
        }
        return url;
    }

    private List<Header> getHeaders(Message message) throws Exception {
            Enumeration allHeaders = message.getAllHeaders();
            List<Header> headers = new ArrayList<Header>();
            while (allHeaders.hasMoreElements()) {
                Header hdr = (Header) allHeaders.nextElement();
                headers.add(hdr);
            }
            return headers;
        }
}

I would like to keep getUrl with MessageBean, but am willing to break that method out to another class. However, which class, and how to reference it? just something like MyBeanOps or something?

  • 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-01T13:13:53+00:00Added an answer on June 1, 2026 at 1:13 pm

    As to your first attempt,

    <h:outputText value="#{messageBean.foo(m.header("Archived-at"))}" />
    

    This fails because you’re ending the attribute value too soon and then starting with an invalid attribute name=value syntax. Pay attention to the syntax highlighting. Use single quotes instead of double quotes for the nested strings:

    <h:outputText value="#{messageBean.foo(m.header('Archived-at'))}" />
    

    As to your second attempt,

    <h:commandLink action="#{bean.insert(item.id)}" value="insert" />
    

    I’m not sure why that fails for you as it seems legit syntax.

    As to your third attempt for which you didn’t show any code but only the error message,

    /foo/client.xhtml @48,61 value="#{messageBean.url(m)}": Method url not found
    

    That’s because you don’t have a method url(Message message). Instead you have a method getUrl(Message message). So you should use

    <h:commandLink action="#{messageBean.getUrl(m)}" value="insert" />
    

    However, that won’t fix the problem. This is namely not a valid action method. This should just be treated as a value expression. So, this should do:

    <a href="#{messageBean.getUrl(m)}">insert</a>
    

    This will print the result of URL#toString() as value of href attribute, which is exactly what you want. You can of course also use a <h:outputLink> for this:

    <h:outputLink value="#{messageBean.getUrl(m)}">insert</h:outputLink>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a client which connects to a Web service to get some information.
The current application uses Simple Java Mail to send couple emails a day but
I am trying to get a Android device to send some information to a
I want to implement in my application the option to send the current user
Want to send the text from my current vb application to the Active Window
We send out registration urls to clients via email. Some of the email clients
I'm attempting to send a .proto message from an iPhone application to a Java
I'm running a java app which creates a visual display of some of the
I'm trying to create my own implementation of javax.net.ssl.SSLSocketFactory , in order to catch
I have implement the simple TCP server and TCP client classes which can send

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.