Hi All,
 
         Has anybody worked with Shale on Websphere Portal 5.1 and
RAD.?????
         I am not getting any refernece on the net.
         If yes then please help me to get shale up and running on
Websphere.
         I am getting the exception : "Exception during portlet
initialization".
 
         Adrian in the mean time i am trying to use shale-core.jar
source code for token.
         a) component-Token
         b) renderer-TokenRenderer
         c) taglib-TokenTag
         d) utils-TokenProcessor
         e) META-INF-taglib.tld and facesConfig.xml.
         phew... have i missed anything.(its like re-inventing the
wheel)
 
Best Regards,
Pallavi 

________________________________

From: Adrian Mitev [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 18, 2006 5:49 PM
To: MyFaces Discussion
Subject: Re: Double click again.....


You could just download the token's source code and use only the
component without the other features of shale-core


2006/12/18, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: 

        Hi All,
         
        I had posted a similar query earlier to prevent double click of
a form button.
        I could use Shale's <s:token> but i ran into compatibility
issues between RAD6.0.1 and Shale-core.jar1.0.3.
        So i had to give it up and try another approach using
Synchronizer Token pattern as in sytuts.
        Please help me fine tune it.Please go ahead to provide me any
other elegant approach.
        I want to call the method generateSaveToken() from
phaseListener.
        Is it possible.????
         
        Jsp Page
         
        <

        h:form> 

        <h:inputText id="text1"/> 

        <h:inputHidden value="#{visit.saveToken} " />

        <h:commandButton value="Submit" id="button1"
action="#{reqBean.actionMethod}" /> 

        

        </h:form>

        FacesConfig.xml

        <

        managed-bean> 

        <description>Session bean that holds data and delegates needed
by request beans.</description>

        <managed-bean-name>visit</managed-bean-name >

        <managed-bean-class>com.acs.click.Visit</ managed-bean-class>

        <managed-bean-scope>session</managed-bean-scope >

        </managed-bean>

        <managed-bean>

        <description>Some request bean.</description>

        <managed-bean-name>reqBean</managed-bean-name >

        <managed-bean-class>com.acs.click.RequestBean</
managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope >

        <managed-property>

        <property-name>visit</property-name >

        <value>#{sessionScope.visit}</value >

        </managed-property>

        </managed-bean>

        Visit.java

        public class Visit extends BaseBean {
         
         private long activeToken;
         private long receivedToken;
           
         public long getSaveToken() {
                return this.activeToken;
            }
         public void setSaveToken(long aToken) {
                this.receivedToken = aToken;
            }
          public long getActiveToken() {
          return activeToken;
         }
          public void setActiveToken(long activeToken) {
          this.activeToken = activeToken;
         }
         public long getReceivedToken() {
          return receivedToken;
         }
         public void setReceivedToken(long receivedToken) {
          this.receivedToken = receivedToken;
         }
           boolean tokensMatch() {
                return (this.activeToken == this.receivedToken);
            }

        }

        RequestBean.java

        public class RequestBean extends BaseBean  {
          
          public String actionMethod() {
                // prevent identical requests from being processed
                String normalOutcome = "Google-NOT-OK";
                if (this.saveTokenIsInValid() ) 
                    return this.logInvalidSaveAndReturn(normalOutcome);
              
                this.expireSaveToken();
                      
                System.out.println("save token is valid.  attempting to
save....");
                try {
                      // invoke some business logic here
                } catch (Exception exc) {
                      this.generateSaveToken();
                      return null;
                }
                this.generateSaveToken();
               return "success";
            }

        
        BaseBean.java

        public class BaseBean {
         
          protected void generateSaveToken() {
                System.out.println("generateSaveToken()");
                Random random = new Random();
                long token = random.nextLong();
                while (token == 0) {
                    token = random.nextLong();
                }
                System.out.println("Save token generated =>"+ token);
                this.getVisit().setActiveToken(token);
                this.getVisit().setReceivedToken(0);
            }
         
                protected boolean saveTokenIsInValid() {
                
               System.out.println("saveTokenIsValid():\n active token: "
+ this.getVisit().getActiveToken() + "\n recv'd token: " +
this.getVisit().getReceivedToken() );
             
                boolean isValid = this.getVisit().tokensMatch();
                return !isValid;
            }
            
                protected void expireSaveToken() {
                System.out.println("expireSaveToken()");
                this.getVisit().setActiveToken(0);
            }

        
              protected String logInvalidSaveAndReturn(String outcome) {
             
             System.out.println("User submitted a save request that was
not " +
                "processed because the save token was not valid.
Returning outcome: '" + outcome + "'.");
              
                return outcome;
            }

        
            // Used by JSF managed bean creation facility
            public Visit getVisit() {
             FacesContext context = FacesContext.getCurrentInstance();
             HttpSession session = (HttpSession)
context.getExternalContext().getSession(false);
             Visit visit = (Visit) session.getAttribute("visit");
             
                return visit;
            }

        
            // Used by JSF managed bean creation facility
            public void setVisit(Visit visit) {
             FacesContext context = FacesContext.getCurrentInstance();
             HttpSession session = (HttpSession)
context.getExternalContext().getSession(false);
             session.setAttribute("visit",visit);
            }

        }

        
        Best Regards,

        Pallavi 
        
        

         

         
         
         

         

         

         
         

The information contained in this electronic message and any attachments
to this message are intended for the exclusive use of the addressee(s)
and may contain proprietary, confidential or privileged information. If
you are not the intended recipient, you should not disseminate,
distribute or copy this e-mail. Please notify the sender immediately and
destroy all copies of this message and any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient
should check this email and any attachments for the presence of viruses.
The company accepts no liability for any damage caused by any virus
transmitted by this email. 

www.wipro.com
        





The information contained in this electronic message and any attachments to 
this message are intended for the exclusive use of the addressee(s) and may 
contain proprietary, confidential or privileged information. If you are not the 
intended recipient, you should not disseminate, distribute or copy this e-mail. 
Please notify the sender immediately and destroy all copies of this message and 
any attachments. 

WARNING: Computer viruses can be transmitted via email. The recipient should 
check this email and any attachments for the presence of viruses. The company 
accepts no liability for any damage caused by any virus transmitted by this 
email.
 
www.wipro.com

Reply via email to