Re: Tag Only Works Within a Request?

2006-02-04 Thread Mike Duffy

It seems like the best way to do this is to create a PhaseListener, "that moves 
messages from the
FacesContext to the user's session and back in the appropriate phases of the 
JSF lifecycle. "

Please see Variant 2:

http://jsffaq.com/Wiki.jsp?ptitle=How+to+show+Faces+Message+on+the+Next+Page%3F&page=HowToShowFacesMessageOnTheNextPage

I think this approach can be greatly simplified by not getting all the messages 
from the
FacesContext, then cycling through the messages and removing the client 
specific messages, then
putting the remaining messages into the session,  Rather, in most cases you are 
going to know the
message or messages you want to appear on the next page; it will be much 
simpler to place these
messages directly into a collection which is held in the session, and then all 
the PhaseListener
has to do is check the session object and get the messages at the beginning of 
the next cycle and
then put the messages into the FacesContext.

It seems like a cool approach.  I shall give it a try.

Thx to:  mailto:[EMAIL PROTECTED]">Jesse Wilson

BTW:  Shouldn't this behavior be intrinsic to JSF?

Mike 


--- Mike Duffy <[EMAIL PROTECTED]> wrote:

> It seems that the  tag only works within a request.  If something 
> goes wrong on the
> current page, the messages display fine. 
> 
> What I would like to be able to do is display a message on the next page (in 
> a new request
> scope)
> once the current page has processed.  I can't seem to get this to work.
> 
> Is there a session scope for the ?
> 
> Am I missing something basic?
> 
> Thx.
> 
> Mike
> 
> __
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


returning to same position within a datascroller?

2006-02-04 Thread Tom Butler








Is it possible to return to the same position within a
datascroller after leaving the page and returning (i.e., datatable displays a
large result set; user has scrolled through the data and is on the 3rd
page of data; user selects a record which links them to a detail page; now want
to return the user to the original .jsf page at the same 3rd page of
data within the datascroller)?  If so, how?

 

thanks








Re: How I can read managed property value from faces-config file in class constructor?

2006-02-04 Thread Laurie Harper

Yogesh Chaudhari wrote:

Hi,

I would like to read "show" managed property value in InvoiceBean
class constructor so I can populate different resultset in "invoices"
arraylist to display on page.

Thanks, Yogesh

public class InvoiceBean {
private String show;
   ArrayList invoices;

public InvoiceBean () {
System.out.println("show invoices " + show);  
invoices = getInvoices();
}


  
invoiceALLBean
org.adr.faces.backing.InvoiceBean
request

  show
  java.lang.String
  ALL

  

  
invoicePENDINGBean
org.adr.faces.backing.InvoiceBean
request

  show
  java.lang.String
  PENDING

  
..
..
..




The short answer is you can't. Properties are set on a bean after it's 
constructed (since before it's constructed there's nothing to set a 
property on...).


You have a couple of options:

- call getInvoices() from setShow()

- call getInvoices() lazily when needed, after the show property has 
been set.


I'd recommend the latter but either would work.

L.



Re: How I can read managed property value from faces-config file in class constructor?

2006-02-04 Thread Dennis Byrne
Whem Myfaces loads, it unmarshalls the faces configurations file(s) into an 
object model.  It stores this in application scope, check the source in order 
to find out which attribute key this is, I forget.  You can also just create 
your own.

FacesConfigUnmarshaller _unmarshaller = new 
DigesterFacesConfigUnmarshallerImpl(null);
InputStream is = new FileInputStream(new File(pathToFacesConfig));
FacesConfigDispenser dispenser = new DigesterFacesConfigDispenserImpl();
dispenser.feed(_unmarshaller.getFacesConfig(is, path));

This of course is vendor lock-in.

Dennis Byrne

>-Original Message-
>From: Yogesh Chaudhari [mailto:[EMAIL PROTECTED]
>Sent: Saturday, February 4, 2006 05:08 PM
>To: 'MyFaces Discussion'
>Subject: How I can read managed property value from faces-config file in class 
>constructor?
>
>Hi,
>
>I would like to read "show" managed property value in InvoiceBean
>class constructor so I can populate different resultset in "invoices"
>arraylist to display on page.
>
>Thanks, Yogesh
>
>public class InvoiceBean {
>   private String show;
>   ArrayList invoices;
>
>   public InvoiceBean () {
>   System.out.println("show invoices " + show);
>   invoices = getInvoices();
>   }
>
>
>  
>invoiceALLBean
>org.adr.faces.backing.InvoiceBean
>request
>
>  show
>  java.lang.String
>  ALL
>
>  
>
>  
>invoicePENDINGBean
>org.adr.faces.backing.InvoiceBean
>request
>
>  show
>  java.lang.String
>  PENDING
>
>  
>.
>.
>.
>
>




Tag Only Works Within a Request?

2006-02-04 Thread Mike Duffy
It seems that the  tag only works within a request.  If something 
goes wrong on the
current page, the messages display fine. 

What I would like to be able to do is display a message on the next page (in a 
new request scope)
once the current page has processed.  I can't seem to get this to work.

Is there a session scope for the ?

Am I missing something basic?

Thx.

Mike

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


How I can read managed property value from faces-config file in class constructor?

2006-02-04 Thread Yogesh Chaudhari
Hi,

I would like to read "show" managed property value in InvoiceBean
class constructor so I can populate different resultset in "invoices"
arraylist to display on page.

Thanks, Yogesh

public class InvoiceBean {
private String show;
   ArrayList invoices;

public InvoiceBean () {
System.out.println("show invoices " + show);
invoices = getInvoices();
}


  
invoiceALLBean
org.adr.faces.backing.InvoiceBean
request

  show
  java.lang.String
  ALL

  

  
invoicePENDINGBean
org.adr.faces.backing.InvoiceBean
request

  show
  java.lang.String
  PENDING

  
.
.
.



UISelectOne or UISelectMany with spread layout in HtmlPanelGrid

2006-02-04 Thread Matthias Kahlau
Hi!


If I add a UISelectOne or UISelectMany component with spread layout as child
to a HtmlPanelGrid, does this component count as child or not.

In JSP, I think it doesn't count as child, but the single HtmlRadio or
HtmlCheckbox components. This is what I'd expect when I build the UI
programmatically. If it does also count as child, I have a problem...


Regards,

Matthias



Re: Best Way to Get Request Parameters

2006-02-04 Thread Mike Duffy

Perfect.

Thx Matthias

--- Matthias Wessendorf <[EMAIL PROTECTED]> wrote:

> Hi Mike
> 
> > HttpServletRequest request =
> > 
> > (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
> >
> > String someParameterValue = 
> > request.getParameter(Constants.SOME_PARAMETER_KEY);
> >
> > I have a feeling that this is not the best way.  Is there some methodology 
> > in JSF that allows
> me
> > to hide the HttpServletRequest?  Any suggestions?
> 
> yes! Faces provides a Map for HTTP parameters. Call this:
> 
> Map params = 
> FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
> 
> params.get(Constants.SOME_PARAMETER_KEY);
> 
> so you are not tied to Servlet API inside of your backing beans.
> 
> 
> Copy and paste from getRequestParameterMap()'s JavaDoc:
> 
> 
> Servlet: This must be the set of parameters available via the
> javax.servlet.ServletRequest methods getParameter() and
> getParameterNames().
> 
> Portlet: This must be the set of parameters available via the
> javax.portlet.PortletRequest methods getParameter() and
> getParameterNames().
> 
> 
> HTH,
> Matthias
> 


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Re: Panel Grid custom component

2006-02-04 Thread Ali Raza
Hey Volker,I tried to add the components as you have instructed but nothing at all gets rendered that way. i wonder if im inheriting my component from the right base class  UIPanel in my case any how the code im trying now is:
    public void encodeBegin( FacesContext context )    {    try    {    ResponseWriter writer = context.getResponseWriter();    writer.writeComment("* THIS IS THE START OF COMPONENT **");
        HtmlPanelGrid panelGrid = new HtmlPanelGrid();    List children = panelGrid.getChildren();        panelGrid.setColumns(2);        UIOutput labelName = new UIOutput();
    labelName.setValue("Enter name: ");    panelGrid.getChildren().add(labelName);        UIInput inputName = new UIInput();    children.add(inputName);
        UIOutput labelAge = new UIOutput();    labelAge.setValue("Enter age: ");    children.add(labelAge);        UIInput inputAge = new UIInput();
    children.add(inputAge);        this.getChildren().add(panelGrid);    super.encodeBegin(context);         writer.writeComment("* THIS IS THE END OF COMPONENT **");
    }    catch( IOException e )    {    }    }  Thanx a lot for your help though ...AliOn 2/3/06, 
Volker Weber <[EMAIL PROTECTED]> wrote:
Hi Ali,there are some things you made wrong:First, and this seems to be a popular error: you can't add a componentto another by setting the parent of the child! useparent.getChildren().add(child) instead.
Than: You dont neet to invoke encoding on every component, just createthen component tree and let jsf do the rest.Try this :public void encodeBegin( FacesContext context ){   HtmlPanelGrid panelGrid = new HtmlPanelGrid();
   panelGrid.setColumns(2);   List children = panelGrid.getChildren();   UIOutput labelName = new UIOutput();   labelName.setValue("Enter name: ");   labelName.setId("nameId");
   children.add(labelName);   UIInput inputName = new UIInput();   inputName.setId("inputNameId");   // UIInput needs a valueBinding   children.add(inputName);   UIOutput labelAge = new UIOutput();
   labelAge.setValue("Enter age: ");   labelName.setId("ageId");   children.add(labelAge);   UIInput inputAge = new UIInput();   inputAge.setId("inputAgeId");   // UIInput needs a valueBinding
   children.add(inputAge);   this.getChildren.add(panelGrid);   super.encodeBegin(context);}Regards,  VolkerAli Raza wrote:> Greetings again,>> Instead of adding components by rendering the htl myself i am adding
> chilid components and calling their encode methods as following:>> public void encodeBegin( FacesContext context )> {> try> {> ResponseWriter writer = 
context.getResponseWriter();> writer.writeComment("* THIS> IS THE START OF COMPONENT> **");>
> HtmlPanelGrid panelGrid = new HtmlPanelGrid();> panelGrid.setColumns(2);> panelGrid.encodeChildren(context);>> addComponentBegin(context, "panelGridId", this, panelGrid);
> addComponentEnd(context, panelGrid);>> UIOutput labelName = new UIOutput();> labelName.setValue("Enter name: ");> addComponentBegin(context, "nameId", panelGrid, labelName);
> addComponentEnd(context, labelName);>> UIInput inputName = new UIInput();> addComponentBegin(context, "inputNameId", panelGrid, inputName);> addComponentEnd(context, inputName);
>> UIOutput labelAge = new UIOutput();> labelAge.setValue("Enter age: ");> addComponentBegin(context, "ageId", panelGrid, labelAge);> addComponentEnd(context, labelAge);
>> UIInput inputAge = new UIInput();> addComponentBegin(context, "inputAgeId", panelGrid, inputAge);> addComponentEnd(context, inputAge);>
 writer.writeComment("* THIS> IS THE END OF COMPONENT> **");> }
> catch( IOException e )> {>> }> }>> public static void addComponentBegin( FacesContext context, String> componentId, UIComponent parentComponent, UIComponent childComponent )
> throws IOException> {> if( componentId != null )> {> childComponent.setId( componentId );> }>> childComponent.setParent
( parentComponent );> childComponent.encodeBegin ( context );> }>> public static void addComponentEnd( FacesContext context,> UIComponent childComponent ) throws IOException
> {>

weird error when using jscookmenu / not sure w here problem is

2006-02-04 Thread Marco Mistroni
hello all,  i have a webapp that uses myfaces..as menu of application, i have always used struts-menu and everythingworked fine.. so i decided to move to use jscookmenu.Menu is displayed fine, however something weird is happening
when i clikc on one menu item, i am redirected to the proper page (i am using tiles)but when i complete hte form on the page and click 'submit', my backed  bean is neverinvoked...i cant understand where the problem is
can anyone help me out? my app works with in-memory database, so in extreme casei can mail it privatelybut what i don't understand is why the page doesnot get submittedhere is a brief of my navigation rules..
 navigation rule ***       *   go_to_insertExpense
 /insert.jsp       go_to_queryExpense   /query.jsp
     go_to_modifyExpense   /modify.jsp  
 end of navigation rule ***AND HTIS is the source of the page, if it can help source  **<
HTML>  	Insert Entrytitle>	  HEAD
><body bgcolor="#ff" text=
"#00" link="#023264" alink="#023264" 
vlink="#023264"><table border="0" 
width="100%" cellspacing="5"><
tr>  <td colspan="2"> This should be a proper header.td>tr><tr>  <td width=
"140" valign="top"><head><script
 type="text/_javascript_" src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/navmenu.jscookmenu.HtmlJSCookMenuRenderer/JSCookMenu.js"
>script><script type="text/_javascript_" 
src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/navmenu.jscookmenu.HtmlJSCookMenuRenderer/MyFacesHack.js"
>script><script type="text/_javascript_"
>script><script type="text/_javascript_" src
="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/theme.js"
>script><link rel="stylesheet" 
href="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/navmenu.jscookmenu.HtmlJSCookMenuRenderer/ThemeOffice/theme.css" 
type="text/css" /><link rel
="stylesheet" href="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/calendar.HtmlCalendarRenderer/WH/theme.css" 
type="text/css" /><link rel
="stylesheet" href="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/calendar.HtmlCalendarRenderer/DB/theme.css" 
type="text/css" /><script
 type="text/_javascript_" src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/prototype.PrototypeResourceLoader/prototype.js"
>script><script type="text/_javascript_" 
src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/calendar.HtmlCalendarRenderer/date.js"
>script><script type="text/_javascript_" 
src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/calendar.HtmlCalendarRenderer/popcalendar.js"
>script><script type="text/_javascript_" 
src="/TestJSFApp/faces/myFacesExtensionResource/org.apache.myfaces.renderkit.html.util.MyFacesResourceLoader/11390689/inputTextHelp.HtmlTextHelpRenderer/inputTextHelp.js"
>script>  <meta HTTP-EQUIV="Content-Type" 
CONTENT="text/html;charset=UTF-8" />  <title>MyFaces - the free JSF Implementationtitle>  <link rel="stylesheet" type
="text/css" href="css/basic.css" />
head>	<script type
="text/_javascript_">script><div id="idJsp0_menu">
div><script type="text/_javascript_">script>  td>  <td valign=
"top"  align="left"><form id
="entryForm" name="entryForm" method=
"post" action="/TestJSFApp/insert.jsf" enctype="application/x-www-form-urlencoded"
><table border="0"><tbody><
tr><td>td><td>td><td>td>tr>tbody>table><table
 border="0"><tbody><tr><td><
label for="entryForm:date">Datelabel>td><
td><input id="entryForm:date" name=
"entryForm:date" type="text" onfocus="selectText('null', 'entryForm:date')" 
onclick="selectText('null', 'entryForm:date')" value="" 
/><span id="entryForm:dateSpan">
span><script type="text/_javascript_">script>td><td>td>tr><tr><td><label
 for="entryForm:description">Descriptionlabel>td><td><
input id="entryForm:description" name="entryForm:description" 
type="text" value="" 
/>td><td>td>tr><tr><
td>Typetd><td><select id=
"entryForm:type" name="entryForm:type" size="1"
>	<option value="99">Testoption>
select>td><td>td>tr><tr><
td><label for="entryForm:amount">Amountlabel
>td><td><input id="entryForm:amount" 
name="entryForm:amount" type="text" 
value="0.0" />td><td>td
>tr>tbody>table><input id=
"entryForm:submitInsert" name="entryForm:submitInsert" type=
"submit" value="Insert" onclick="clear_entryForm();document.forms['entryForm'].elements['autoS</pre></span>
</blockquote><br>

<h3><span class=subject><a href="/users@myfaces.apache.org/msg16233.html">Re: Best Way to Get Request Parameters</a></span></h3>
<div class="darkgray font13">
<span class="sender pipe">
<span class=date><a href="/search?l=users%40myfaces.apache.org&q=date:20060204&o=newest&f=1">2006-02-04</a></span></span>
<span class="sender pipe">
<span class=thead><a href="/search?l=users%40myfaces.apache.org&q=subject:%22Best+Way+to+Get+Request+Parameters%22&o=newest&f=1">Thread</a></span></span>
<span class=name><a href="/search?l=users%40myfaces.apache.org&q=from:%22Matthias+Wessendorf%22&o=newest&f=1">Matthias Wessendorf</a></span>
</div>
<blockquote><span class="msgFragment"><pre>
Hi Mike

> HttpServletRequest request =
> 
> (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
>
> String someParameterValue = 
> request.getParameter(Constants.SOME_PARAMETER_KEY);
>
> I have a feeling that this is not the best way.  Is there some methodology in 
> JSF that allows me
> to hide the HttpServletRequest?  Any suggestions?

yes! Faces provides a Map for HTTP parameters. Call this:

Map params = 
FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();

params.get(Constants.SOME_PARAMETER_KEY);

so you are not tied to Servlet API inside of your backing beans.


Copy and paste from getRequestParameterMap()'s JavaDoc:


Servlet: This must be the set of parameters available via the
javax.servlet.ServletRequest methods getParameter() and
getParameterNames().

Portlet: This must be the set of parameters available via the
javax.portlet.PortletRequest methods getParameter() and
getParameterNames().


HTH,
Matthias

</pre></span>
</blockquote><br>
    <h2></h2>
  </div>
  <div class="aside" role="complementary">
    <div class="logo">
      <a href="/"><img src="/logo.png" width=247 height=88 alt="The Mail Archive"></a>
    </div>
    <h2>11 matches</h2>
    <br>
    
<ul><li><a href="/search?l=users%40myfaces.apache.org&q=date%3A20060204&a=1&o=newest&f=1">Advanced search</a></li></ul>
<form class="overflow" action="/search" method="get">
<input type="hidden" name="l" value="users@myfaces.apache.org">
<label class="hidden" for="q">Search the list</label>
<input class="submittext" type="text" id="q" name="q" placeholder="Search users" value="date:20060204">
<input class="submitbutton" id="submit" type="image" src="/submit.png" alt="Submit">
</form>

    
    <div class="nav margintop" id="nav" role="navigation">
      <h2 class="hidden">
                               Site Navigation
      </h2>
      <ul class="icons font16">
        <li class="icons-home"><a href="/">The Mail Archive home</a></li>
        <li class="icons-list">
          <a href="/users@myfaces.apache.org" title="c" id="c">users - all messages</a></li>
        <li class="icons-about">
          <a href="/users@myfaces.apache.org/info.html">users  - about the list</a></li>
        <li class="icons-expand"><a href="/search?l=users%40myfaces.apache.org&q=date%3A20060204&o=newest" title="e" id="e">Expand</a></li>
      </ul>
    </div>

    <div class="listlogo margintopdouble">
      <h2 class="hidden">
  				Mail list logo
      </h2>
      <a href="/users@myfaces.apache.org"><img src="/users@myfaces.apache.org/logo.png" alt="aims"></a>
    </div>
  </div>
  <div class="footer" role="contentinfo">
    <h2 class="hidden">
	        	      Footer information
    </h2>
    <ul>
      <li><a href="/">The Mail Archive home</a></li>
      <li><a href="/faq.html#newlist">Add your mailing list</a></li>
      <li><a href="/faq.html">FAQ</a></li>
      <li><a href="/faq.html#support">Support</a></li>
      <li><a href="/faq.html#privacy">Privacy</a></li>
    </ul>
  </div>
<script language="javascript" type="text/javascript">
document.onkeydown = NavigateThrough;
function NavigateThrough (event)
{
  if (!document.getElementById) return;
  if (window.event) event = window.event;
  if (event.target.tagName == 'INPUT') return;
  if (event.ctrlKey || event.metaKey) return;
  var link = null;
  switch (event.keyCode ? event.keyCode : event.which ? event.which : null) {
    case 69:
      link = document.getElementById ('e');
      break;
    }
  if (link && link.href) document.location = link.href;
}
</script>
</body>
</html>