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

The Archive Base Latest Questions

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

I use this questions to create a composite component with the behaviour of a

  • 0

I use this questions to create a composite component with the behaviour of a time selector.

This is my composite xhtml

<ui:composition xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:cc="http://java.sun.com/jsf/composite"
xmlns:rich="http://richfaces.org/rich">
<cc:interface componentType="customTimeBean">
    <cc:attribute name="date" type="java.util.Date" required="true" />
</cc:interface>
<cc:implementation>
    <rich:inputNumberSpinner value="#{cc.hours}" minValue="0"
        maxValue="23" />
    <h:outputLabel value=":" />
    <rich:inputNumberSpinner value="#{cc.minutes}" minValue="0"
        maxValue="59" />
</cc:implementation>
</ui:composition>

This is my Faces Component

@FacesComponent(value = "customTimeBean")
public class CustomTimeBean extends UINamingContainer {

    private Date getDate() {

        Date d = (Date) getAttributes().get("date");
        if (d == null) {
            //throw new RuntimeException("Date no debe ser nulo");
            d = new date();
        }
        return d;
    }

    public void setMinutes(int value) {

        getDate().setMinutes(value);
    }

    public void setHours(int value) {

        getDate().setHours(value);
    }

    public int getMinutes() {

        return getDate().getMinutes();
    }

    public int getHours() {

        return getDate().getHours();
    }

    public void setSeconds(int value) {

        getDate().setHours(value);
    }

    public int getSeconds() {

        return getDate().getSeconds();
    }

}

And the usage

<sigh:time date="#{bean.date}" hasSeconds="false"/>

My test case:

<h:outputLabel value="#{controller.date}" id="date" />
<sigh:time date="#{controller.date}" />
<a4j:commandButton render="date" />

The “controller”:

@ManagedBean
public class Controller  {

    Date date;

    public Date getDate() {

        return date;
    }

    public void setDate(Date date) {

        this.date = date;
    }
}     

This works well, but, this doesn’t work when I pass a null Date as attribute, how can I update the value in the Bean (controller.date)?

In my test case, when I press the a4j:commandButton and date in the controller is null, the outputlabel dont show nothing (date is null), when the date is not null, the date is update everytime I click the Button.

Sorry for my bad english.

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-06-16T10:47:50+00:00Added an answer on June 16, 2026 at 10:47 am

    Just replace

    throw new RuntimeException("Date no debe ser nulo");
    

    by

    d = new Date();
    

    Unrelated to the concrete problem, the Date methods which you’re using there are deprecated. See also the javadoc. The main reason is that it doesn’t deal with timezones/DST properly. You should internally in the composite be using java.util.Calendar instead.

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

Sidebar

Related Questions

Sorry to follow this topic http://stackoverflow.com/questions/11044825/javascript-run-on-ie-7 I want to use document.GetElementByClassName ON INTERNET EXPLORE
This is a design question: when do I need to create/use a static method
This questions concerns the use of the formula field in a static mapping block
I want to create an application that support Youtube API. I use this tutorial
Following this question , I use this function to convert arrays to objects, function
In answering this question , it got me thinking... I often use this pattern:
I don't know which title I should use for this question. I have a
In this question it has been shown how to use neat boolean variables in
This question originates from a discussion on whether to use SQL ranking functionality or
This question is hard to phrase, so I'm going to have to use some

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.