Re: Validate HTML generated from getMarkupResourceStream()

2008-04-03 Thread hjuturu

Hi Igor,All
I tried to use MarkupParser as u suggested
This is how my code looks
public IResourceStream getMarkupResourceStream(MarkupContainer container,
Class containerClass){
   IResourceStream rStream = new StringResourceStream(HTMLString);
MarkupResourceStream resource = new 
MarkupResourceStream(rStream);
MarkupParser parser = new MarkupParser(resource);
try {

parser.parse();
} catch (Exception e) {
 setRedirect(true);
setResponsePage(ParseError.class);
}

return rStream;
}

What is really weird is that though the the exception is caught in the catch
block, the program flow continues to return rStream;  statement and throws
the error on the console again. It doesnt go to the response page that i set
in the catch block.

I am not sure why this happens ?
Thanks
Haritha


igor.vaynberg wrote:
 
 you can probably user our markupparser...
 
 -igor
 
 
 On Tue, Apr 1, 2008 at 1:26 PM, hjuturu [EMAIL PROTECTED] wrote:

  Hi All
  I use a class which implements IMarkupResourceStreamProvider,
  IMarkupCacheKeyProvider to
  generated HTML dynamically and sent it to wicket as a IResourceStream.
  //code snippet
  public IResourceStream getMarkupResourceStream(MarkupContainer
 container,
  Class containerClass){ return new
 StringResourceStream(HTMLString);
 }

  If the HTMLString is not properly formed , wicket throws
  java.text.ParseException and org.apache.wicket.markup.MarkupException.
  after i set the responsepage.

  I would like to validate whether this string is correct before it goes
 to
  wicket code and a exception is thrown.Is there anyway to validate this
  HTMLString and catch the exception.

  If not in wicket are there any third party packages available to
 validate
  dynamically generated HTML strings .

  Thanks All
  Haritha





  --
  View this message in context:
 http://www.nabble.com/Validate-HTML-generated-from-getMarkupResourceStream%28%29-tp16423755p16423755.html
  Sent from the Wicket - User mailing list archive at Nabble.com.


  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Validate-HTML-generated-from-getMarkupResourceStream%28%29-tp16423755p16468359.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Validate HTML generated from getMarkupResourceStream()

2008-04-03 Thread hjuturu

I got a solution for this and would like to share it with those interested
I replaced the catch block with this code'

catch (Exception e) {
getSession().error(Parse Exception Occured);
throw new 
RestartResponseException(ParseError.class); 

}

Thanks
Haritha

hjuturu wrote:
 
 Hi Igor,All
 I tried to use MarkupParser as u suggested
 This is how my code looks
 public IResourceStream getMarkupResourceStream(MarkupContainer container,
 Class containerClass){
  IResourceStream rStream = new StringResourceStream(HTMLString);
   MarkupResourceStream resource = new 
 MarkupResourceStream(rStream);
   MarkupParser parser = new MarkupParser(resource);
   try {
   
   parser.parse();
   } catch (Exception e) {
  setRedirect(true);
   setResponsePage(ParseError.class);
   }
 
   return rStream;
 }
 
 What is really weird is that though the the exception is caught in the
 catch block, the program flow continues to return rStream;  statement
 and throws the error on the console again. It doesnt go to the response
 page that i set in the catch block.
 
 I am not sure why this happens ?
 Thanks
 Haritha
 
 
 igor.vaynberg wrote:
 
 you can probably user our markupparser...
 
 -igor
 
 
 On Tue, Apr 1, 2008 at 1:26 PM, hjuturu [EMAIL PROTECTED] wrote:

  Hi All
  I use a class which implements IMarkupResourceStreamProvider,
  IMarkupCacheKeyProvider to
  generated HTML dynamically and sent it to wicket as a IResourceStream.
  //code snippet
  public IResourceStream getMarkupResourceStream(MarkupContainer
 container,
  Class containerClass){ return new
 StringResourceStream(HTMLString);
 }

  If the HTMLString is not properly formed , wicket throws
  java.text.ParseException and
 org.apache.wicket.markup.MarkupException.
  after i set the responsepage.

  I would like to validate whether this string is correct before it goes
 to
  wicket code and a exception is thrown.Is there anyway to validate this
  HTMLString and catch the exception.

  If not in wicket are there any third party packages available to
 validate
  dynamically generated HTML strings .

  Thanks All
  Haritha





  --
  View this message in context:
 http://www.nabble.com/Validate-HTML-generated-from-getMarkupResourceStream%28%29-tp16423755p16423755.html
  Sent from the Wicket - User mailing list archive at Nabble.com.


  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]


 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Validate-HTML-generated-from-getMarkupResourceStream%28%29-tp16423755p16469586.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Validate HTML generated from getMarkupResourceStream()

2008-04-01 Thread hjuturu

Hi All
I use a class which implements IMarkupResourceStreamProvider,
IMarkupCacheKeyProvider to 
generated HTML dynamically and sent it to wicket as a IResourceStream.
//code snippet
public IResourceStream getMarkupResourceStream(MarkupContainer container,
Class containerClass){ return new 
StringResourceStream(HTMLString);
}

If the HTMLString is not properly formed , wicket throws
java.text.ParseException and org.apache.wicket.markup.MarkupException.
after i set the responsepage. 

I would like to validate whether this string is correct before it goes to
wicket code and a exception is thrown.Is there anyway to validate this
HTMLString and catch the exception.

If not in wicket are there any third party packages available to validate
dynamically generated HTML strings .

Thanks All
Haritha





-- 
View this message in context: 
http://www.nabble.com/Validate-HTML-generated-from-getMarkupResourceStream%28%29-tp16423755p16423755.html
Sent from the Wicket - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]