PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 13, 2022

[FIXED] How to limit height of JSF <h:messages> component

 July 13, 2022     facescontext, jsf, limit, messages, numbers     No comments   

Issue

I have the wrapped into my own faces component. Right now we found that when adding several messages the are of the expands moving the actual page components to the very far bottom of the page.

It's not viable to change the 300 pages we have on this system. Tried to find way to limit the height of the <h:messages> by CSS with no success.

The bright side is that when adding messsages to the current faces context is required that caller uses a method from the super class. I was able to limit the messages, but my control variables are not reseting when the page is reloaded.

My question, is there any other way to limit the messages from faces context?

(using javaEE5, JSF 1.1, tomcat5)


Solution

Here is what I did to workaround the problem. As I said on my original post the component I use is wrapped. I overwrote the encodeBegin and encodeEnd to wrap the original h:messages with a div element:

import java.io.IOException;
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlMessages;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.el.ValueBinding;

public class UIMessages extends HtmlMessages implements LayoutComponent {

  public void encodeBegin(FacesContext context) throws IOException{
    ResponseWriter writer = context.getResponseWriter();
    layout.startRow(writer);
    layout.startData(writer);
    writer.startElement("div", this);
    writer.writeAttribute("style", "overflow:auto; border:0px solid; max-height:100px;", null);
    super.encodeBegin(context);
  }

  public void encodeEnd(FacesContext context) throws IOException{
      ResponseWriter writer = context.getResponseWriter();
      super.encodeEnd(context);
      writer.endElement("div");
      layout.endData(writer);
      layout.endRow(writer);
  }
}


Answered By - ChRoNoN
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing