myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anil Kommareddi" <anil.kommare...@effone.com>
Subject RE: from-outcome value
Date Thu, 21 Dec 2006 13:52:02 GMT
Thanks Marco, that is exactly what we have been doing.
 
Here is one way that I thought of doing if anyone else is interested: 
 
Define the outcomes in a properties file and use an ANT filterset to use
this properties file to replace the outcomes in the faces-config.xml during
the build process. To take your example, the Outcomes class would contain a
method like this:
 
public static String getOutcome(String id) {
    return getResourceString(ResourceUtils.TYPE_OUTCOMES, id);
}
 
The navigation rule would look like this:
<navigation-case>
    <from-outcome>@OUTCOME.CONTINUE@</from-outcome>
    <to-view-id>/somepage.jsp</to-view-id>
</navigation-case>

and the Outcomes properties file will contain:
 
OUTCOME.CONTINUE=continue
 
While this works, if anyone has a more elegant solution, I would love to see
it.
 
Thanks for your response.
- Anil.

  _____  

From: Beelen, Marco [mailto:marco_beelen@merck.com] 
Sent: Thursday, December 21, 2006 4:01 AM
To: MyFaces Discussion
Subject: RE: from-outcome value


Anil,
 
There is no way you can specify the name of an outcome just once and use a
reference to it both in the java-code of your managed-bean and the
navigation-rules in your faces-config.xml. Since your faces-config.xml
doesn't get build or compile, there is no way to garantee that the values
used for outcomes are 'valid' and match the String you use in the
managed-bean.
 
For me it works fine to create a Outcomes-class which contains a set of
static final String for all outcomes I use through out the entire
application. It allows to reference to those outcomes in your managed-bean
and set JavaDoc on the outcome-constants to spefify the String to use in the
faces-config.xml.
 
public class Outcomes {
    /**
     * Outcome use to proceed to the next step in a wizard: "continue".
     */
    public static final String CONTINUE = "continue";
}
 
managed-bean:
 
public String someMethod() {
  return Outcomes.CONTINUE;
}
 
This doesn't prevent you from making mistakes and errors in typing the value
for from-outcome, but does offer you the possibility to re-use your code
better and made changes easier by allowing you to refactor your code instead
of performing 'global' search and replace-action on your Strings used as
outcomes.
 
With kind regards,
  Marco Beelen
 
 
 
 
 
 
 
 
  _____  

From: Anil Kommareddi [mailto:anil.kommareddi@effone.com] 
Sent: woensdag 20 december 2006 20:00
To: users@myfaces.apache.org
Subject: OT: from-outcome value


Folks,
Has anyone devised or know of a pattern to be able to use a reference to a
constant string or property file in the from-outcome tag of a
navigation-case instead of 'hardcoding' the actual string there?

My objective here is to maintain a common repository of outcomes either in a
class or property file and refer to them from both the action method and the
navigation case.

Thanks - Anil.



----------------------------------------------------------------------------
--

Notice:  This e-mail message, together with any attachments, contains

information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station,

New Jersey, USA 08889), and/or its affiliates (which may be known

outside the United States as Merck Frosst, Merck Sharp & Dohme or MSD

and in Japan, as Banyu - direct contact information for affiliates is 

available at http://www.merck.com/contact/contacts.html) that may be 

confidential, proprietary copyrighted and/or legally privileged. It is 

intended solely for the use of the individual or entity named on this 

message. If you are not the intended recipient, and have received this 

message in error, please notify us immediately by reply e-mail and then 

delete it from your system.



----------------------------------------------------------------------------
--


Mime
View raw message