How to get URLs for images with in a WebApp

2013-08-28 Thread Andun Sameera
Hi All,

I have a use case like this which needs some help. There is folder in my
web app called images. There are some images in that folder which are
dynamically added. In my application, I want to list down URLs for all
these images. Can any one give me some hints ?

Thanks!

-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


Re: How to get URLs for images with in a WebApp

2013-08-28 Thread Andun Sameera
Hi Maxim,

I tried that method. In my web app I can access a image using this url,

http://localhost:8080/ClipArts/images.jpeg

Then I tried,

((WebApplication)
WebApplication.get()).getServletContext().getRealPath(ClipArts)
((WebApplication)
WebApplication.get()).getServletContext().getRealPath(ClipArts/images.jpeg)
((WebApplication)
WebApplication.get()).getServletContext().getRealPath(/ClipArts/images.jpeg)

Each of these cases it return null. Also I am suing this code inside a
Constructor of a Custom behavior. What can be the reason?

Thanks!



On Wed, Aug 28, 2013 at 4:46 PM, Maxim Solodovnik solomax...@gmail.comwrote:

 ((WebApplication) WebApplication.get()).getServletContext()
 .getRealPath(images)


 On Wed, Aug 28, 2013 at 6:11 PM, Andun Sameera andun...@gmail.com wrote:

  Hi All,
 
  I have a use case like this which needs some help. There is folder in my
  web app called images. There are some images in that folder which are
  dynamically added. In my application, I want to list down URLs for all
  these images. Can any one give me some hints ?
 
  Thanks!
 
  --
  Regards
  Andun S.L. Gunawardana
  Undergraduate
  Department of Computer Science And Engineering
  University of Moratuwa
  Sri Lanka
 
  Blog - http://www.insightforfuture.blogspot.com/
  LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
  Twitter -http://twitter.com/AndunSLG
 



 --
 WBR
 Maxim aka solomax




-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


Re: How to get URLs for images with in a WebApp

2013-08-28 Thread Andun Sameera
Hi,

It was a issue with my IDE integration. I am running the webapp via Tomcat
in IntellijIDEA. It runs the wicket application in the bin folder of
Tomcat. Thus some issue arises. Then I tried manually with Tomcat. Then it
works.

Thanks!


On Wed, Aug 28, 2013 at 4:59 PM, Andun Sameera andun...@gmail.com wrote:

 Hi Maxim,

 I tried that method. In my web app I can access a image using this url,

 http://localhost:8080/ClipArts/images.jpeg

 Then I tried,

 ((WebApplication)
 WebApplication.get()).getServletContext().getRealPath(ClipArts)
 ((WebApplication)
 WebApplication.get()).getServletContext().getRealPath(ClipArts/images.jpeg)
 ((WebApplication)
 WebApplication.get()).getServletContext().getRealPath(/ClipArts/images.jpeg)

 Each of these cases it return null. Also I am suing this code inside a
 Constructor of a Custom behavior. What can be the reason?

 Thanks!



 On Wed, Aug 28, 2013 at 4:46 PM, Maxim Solodovnik solomax...@gmail.comwrote:

 ((WebApplication) WebApplication.get()).getServletContext()
 .getRealPath(images)


 On Wed, Aug 28, 2013 at 6:11 PM, Andun Sameera andun...@gmail.com
 wrote:

  Hi All,
 
  I have a use case like this which needs some help. There is folder in my
  web app called images. There are some images in that folder which are
  dynamically added. In my application, I want to list down URLs for all
  these images. Can any one give me some hints ?
 
  Thanks!
 
  --
  Regards
  Andun S.L. Gunawardana
  Undergraduate
  Department of Computer Science And Engineering
  University of Moratuwa
  Sri Lanka
 
  Blog - http://www.insightforfuture.blogspot.com/
  LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
  Twitter -http://twitter.com/AndunSLG
 



 --
 WBR
 Maxim aka solomax




 --
 Regards
 Andun S.L. Gunawardana
 Undergraduate
 Department of Computer Science And Engineering
 University of Moratuwa
 Sri Lanka

 Blog - http://www.insightforfuture.blogspot.com/
 LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
 Twitter -http://twitter.com/AndunSLG








-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


renderHead vs Behavior Constructor

2013-08-12 Thread Andun Sameera
Hi all,

I have implemented a custom Behviour called WhiteboardBehavior extending
the AbstractDefaultAjaxBehavior. In that class I have a static HashMap like
this,

private static ConcurrentHashMapInteger,Element elementMap=new
ConcurrentHashMapInteger,Element();

In the constructor of my Behavior class I put elements to the map like this,

public WhiteboardBehavior(String whiteboardId,String whiteboardContent){
super();
this.whiteboardId=whiteboardId;
Element element=new Element(whiteboardContent);

if(element!=null){
elementMap.put(element.getId(),element);
}
}

I am trying to execute some JavaScript codes int he renderHead method using
the above added elements. I did it like this,

public void renderHead(Component component, IHeaderResponse response) {
super.renderHead(component,response);

initReferences(response);
String callbackUrl=getCallbackUrl().toString();
String whiteboardInitializeScript= +
callbackUrl='+callbackUrl+';\n +
whiteboard = bay.whiteboard.Create();\n +
elementCollection=whiteboard.getMainCollection();\n+
whiteboard.getMainCollection().onChange =
function(element){\n+
changedElement=this.getJson(element);\n+

Wicket.Ajax.get({u:'+callbackUrl+',ep:{editedElement:changedElement}});\n};\n+

whiteboard.render(document.getElementById('+whiteboardId+'));\n+
whiteboard.setBoundaries(0, 0, 0, 0);\n;

//Clearing the whiteboard for first client
IWebSocketConnectionRegistry reg =
IWebSocketSettings.Holder.get(Application.get()).getConnectionRegistry();
if(reg.getConnections(Application.get()).size()==0){
elementMap.clear();
}

   * //Loading existing content for clients join after first one
if(!elementMap.isEmpty()){
MapInteger,Element sortedElementList = new
TreeMapInteger,Element(elementMap);
JSONArray jsonArray=new JSONArray();
for (Element e : sortedElementList.values()) {
jsonArray.put(e.getJSON());
}

whiteboardInitializeScript+=elementCollection.parseJson('+jsonArray.toString()+');;
}*


response.render(OnDomReadyHeaderItem.forScript(whiteboardInitializeScript));
}

But when renderHead is executed for the first time, the elementMap is
empty. What has gone wrong here?

Thanks!

-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


How to call Java Function from JavaScript

2013-07-03 Thread Andun Sameera
Hi All,

I have looked in to this topic in many places and found some ways. In this
particular scenario, I have used
https://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascriptarticle
as the reference.

What I did in Java,

public class HomePage extends WebPage {
private static final long serialVersionUID = 1L;

public HomePage(final PageParameters parameters) {
super(parameters);


final AbstractDefaultAjaxBehavior behave = new
AbstractDefaultAjaxBehavior() {
protected void respond(final AjaxRequestTarget target) {
target.add(new Label(foo, Yeah I was just called from
Javascript!));
}

public void renderHead(Component component,IHeaderResponse
response){

String componentMarkupId = component.getMarkupId();
String callbackUrl = getCallbackUrl().toString();

response.render(JavaScriptHeaderItem.forScript(var
componentMarkupId='+componentMarkupId+'; var
callbackUrl='+callbackUrl+';,values));
}
};

add(behave);

}

}

and my HomePage.html,

!DOCTYPE HTML
html
body
script src=http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
/script
script type=text/javascript
$(function() {
var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' });
alert(wcall);
});
/script
/body
/html

What I tried to do is call the get ajax method using the vars I have
initialized. But when my page loads, in the firebug console it says,

ReferenceError: Wicket is not defined
[Break On This Error]

var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' });

What has gone wrong here ?

Is there any other good way to call Java Function from Javascript?

Thanks!

-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


Re: How to call Java Function from JavaScript

2013-07-03 Thread Andun Sameera
Thanks Bas! I have fixed the problem.

On Thu, Jul 4, 2013 at 1:10 AM, Bas Gooren b...@iswd.nl wrote:

 Wicket's ajax functions require you to load the wicket ajax javascript.

 This is handled by the AbstractDefaultAjaxBahavior out of the box.
 However, since you do not call super.renderHead(component,**response) in
 your code, the required javascript files are not loaded.

 Met vriendelijke groet,
 Kind regards,

 Bas Gooren

 Op 3-7-2013 19:09, schreef Andun Sameera:

  Hi All,

 I have looked in to this topic in many places and found some ways. In this
 particular scenario, I have used
 https://cwiki.apache.org/**confluence/display/WICKET/**
 Calling+Wicket+from+**Javascriptarticlehttps://cwiki.apache.org/confluence/display/WICKET/Calling+Wicket+from+Javascriptarticle
 as the reference.

 What I did in Java,

 public class HomePage extends WebPage {
  private static final long serialVersionUID = 1L;

  public HomePage(final PageParameters parameters) {
  super(parameters);


  final AbstractDefaultAjaxBehavior behave = new
 AbstractDefaultAjaxBehavior() {
  protected void respond(final AjaxRequestTarget target) {
  target.add(new Label(foo, Yeah I was just called from
 Javascript!));
  }

  public void renderHead(Component component,IHeaderResponse
 response){

  String componentMarkupId = component.getMarkupId();
  String callbackUrl = getCallbackUrl().toString();

  response.render(**JavaScriptHeaderItem.**forScript(var
 componentMarkupId='+**componentMarkupId+'; var
 callbackUrl='+callbackUrl+';**,values));
  }
  };

  add(behave);

  }

 }

 and my HomePage.html,

 !DOCTYPE HTML
 html
 body
 script src=http://ajax.googleapis.**com/ajax/libs/jquery/1.6.1/**
 jquery.min.jshttp://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js
 /script
 script type=text/javascript
  $(function() {
  var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' });
  alert(wcall);
  });
 /script
 /body
 /html

 What I tried to do is call the get ajax method using the vars I have
 initialized. But when my page loads, in the firebug console it says,

 ReferenceError: Wicket is not defined
 [Break On This Error]

 var wcall = Wicket.Ajax.get({ u: '${callbackUrl}' + '' });

 What has gone wrong here ?

 Is there any other good way to call Java Function from Javascript?

 Thanks!





-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


Re: How I get the internal html content of a dynamically updated div tag using Apache Wicket

2013-06-03 Thread Andun Sameera
Hi All,

I have tried further with AjaxEditableLabel in following way to get the
cotent of div tag.

String value=Type.;
AjaxEditableLabel ajaxEditableLabel=new
AjaxEditableLabel(editorArea,new Model(value)){
@Override
public void onEdit(AjaxRequestTarget target){
String value=getEditor().getValue();
System.out.println(value);
}
@Override
protected void onModelChanged() {
String value=getEditor().getValue();
System.out.println(value);
}
@Override
protected void onModelChanging() {
String value=getEditor().getValue();
System.out.println(value);
}
protected void onSubmit(AjaxRequestTarget target){
String value=getEditor().getValue();
System.out.println(value);
}
};
ajaxEditableLabel.setOutputMarkupId(true);
ajaxEditableLabel.setMarkupId(editorArea);
form.add(ajaxEditableLabel);

When this applies Wysiwyg is working properly. The markup is updated. But
the onEdit,onModelChaging methods are not invoked to update the model
object value. Thus what will be the way to get the updated cotent from the
ajax editable label?

Thanks!
On Mon, Jun 3, 2013 at 5:17 AM, Andun Sameera andun...@gmail.com wrote:

 Hi All,

 Also cant we use AjaxEditableMultiLineLabel which is used in [1] for the
 task?

 Thanks!

 [1] -
 http://www.wicket-library.com/wicket-examples/ajax/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.ajax.builtin.EditableLabelPage


 On Sun, Jun 2, 2013 at 10:24 AM, Maxim Solodovnik solomax...@gmail.comwrote:

 Hello Martin,

 Thanks for the reply

 Is it possible to wrap component into its own form and add some behavior
 which will trigger adding DynamicExtraParameters on upper form submit?

 I have added new AjaxFormSubmitBehavior(this, submit) to my component
 form but it is not triggered on upper form submit :(




 On Sat, Jun 1, 2013 at 3:25 PM, Martin Grigorov mgrigo...@apache.org
 wrote:

  Hi Maxim,
 
  It depends what is the markup you have to work with.
  Usually WYSIWYG widgets work with just a div or textarea and create
  other HTML elements dynamically with JavaScript to do their job, e.g. an
  iframe.
  Additionally they almost always give you API to get the produced rich
  content (html, markdown, ...).
  For example:
  var richEditor = $.myWysiwyg(#myTextArea);
  var richContent = richEditor.getContent();
 
  doSomethingWithRichContent(richContent);
 
  So it is not always possible to create 1:1 mapping between the client
 and
  the server usage of form components.
 
 
 
  On Sat, Jun 1, 2013 at 11:11 AM, Maxim Solodovnik solomax...@gmail.com
  wrote:
 
   Hello Martin,
  
   Is it possible to create FormComponentPanel as in following example
  
  
 
 https://cwiki.apache.org/WICKET/creating-custom-formcomponentpanels-to-build-valid-objects-using-wickets-form-validation-logic.html
  
   but taking the value from the div.innerHtml and not the textfield?
  
  
   On Sat, Jun 1, 2013 at 2:19 PM, Martin Grigorov mgrigo...@apache.org
   wrote:
  
Hi,
   
I guess you want to get the new entered text via Ajax submit.
You can extend AjaxSubmitButton and implement
 #updateAjaxAttributes() {
   
   attributes.getDynamicExtraParameters().add(return [ {name:
   'richText',
value: $('#editorArea').html() } ]);
}
   
Then use
   
   
  
 
 getRequest().getRequestParameters().getParameterValue(richText).toString()
to get the produced HTML.
   
   
On Sat, Jun 1, 2013 at 8:04 AM, Andun Sameera andun...@gmail.com
   wrote:
   
 Hi,

 In my html file I have a div tag like this,

 div wicket:id=editorAreaType Here/div

 I am using a JavaScript library called bootstrap-wysiwyg to make
 this
 div tag a text are which we can type rich text. When the person
 types
 text, div tag's html content updates to represent the text
 content in
 html. I want to retrieve it in to the Java code of the html file
 in
 wicket. I tried to do it by creating reference variable to div tag
 like following,

 WebMarkupContainer editorArea=new
 WebMarkupContainer(editorArea);
 String text=editorArea.getMarkup().toString(true)

 But this don't give me the updated HTML content. I give only the
 initial html content. what is the problem here?

 Thanks!

 --
 Regards
 Andun S.L. Gunawardana
 Undergraduate
 Department of Computer Science And Engineering
 University of Moratuwa
 Sri Lanka

 Blog - http://www.insightforfuture.blogspot.com/
 LinkedIn -
   http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
 Twitter -http://twitter.com/AndunSLG

Re: How I get the internal html content of a dynamically updated div tag using Apache Wicket

2013-06-02 Thread Andun Sameera
Hi All,

Also cant we use AjaxEditableMultiLineLabel which is used in [1] for the
task?

Thanks!

[1] -
http://www.wicket-library.com/wicket-examples/ajax/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.ajax.builtin.EditableLabelPage

On Sun, Jun 2, 2013 at 10:24 AM, Maxim Solodovnik solomax...@gmail.comwrote:

 Hello Martin,

 Thanks for the reply

 Is it possible to wrap component into its own form and add some behavior
 which will trigger adding DynamicExtraParameters on upper form submit?

 I have added new AjaxFormSubmitBehavior(this, submit) to my component
 form but it is not triggered on upper form submit :(




 On Sat, Jun 1, 2013 at 3:25 PM, Martin Grigorov mgrigo...@apache.org
 wrote:

  Hi Maxim,
 
  It depends what is the markup you have to work with.
  Usually WYSIWYG widgets work with just a div or textarea and create
  other HTML elements dynamically with JavaScript to do their job, e.g. an
  iframe.
  Additionally they almost always give you API to get the produced rich
  content (html, markdown, ...).
  For example:
  var richEditor = $.myWysiwyg(#myTextArea);
  var richContent = richEditor.getContent();
 
  doSomethingWithRichContent(richContent);
 
  So it is not always possible to create 1:1 mapping between the client and
  the server usage of form components.
 
 
 
  On Sat, Jun 1, 2013 at 11:11 AM, Maxim Solodovnik solomax...@gmail.com
  wrote:
 
   Hello Martin,
  
   Is it possible to create FormComponentPanel as in following example
  
  
 
 https://cwiki.apache.org/WICKET/creating-custom-formcomponentpanels-to-build-valid-objects-using-wickets-form-validation-logic.html
  
   but taking the value from the div.innerHtml and not the textfield?
  
  
   On Sat, Jun 1, 2013 at 2:19 PM, Martin Grigorov mgrigo...@apache.org
   wrote:
  
Hi,
   
I guess you want to get the new entered text via Ajax submit.
You can extend AjaxSubmitButton and implement
 #updateAjaxAttributes() {
   
   attributes.getDynamicExtraParameters().add(return [ {name:
   'richText',
value: $('#editorArea').html() } ]);
}
   
Then use
   
   
  
 
 getRequest().getRequestParameters().getParameterValue(richText).toString()
to get the produced HTML.
   
   
On Sat, Jun 1, 2013 at 8:04 AM, Andun Sameera andun...@gmail.com
   wrote:
   
 Hi,

 In my html file I have a div tag like this,

 div wicket:id=editorAreaType Here/div

 I am using a JavaScript library called bootstrap-wysiwyg to make
 this
 div tag a text are which we can type rich text. When the person
 types
 text, div tag's html content updates to represent the text content
 in
 html. I want to retrieve it in to the Java code of the html file in
 wicket. I tried to do it by creating reference variable to div tag
 like following,

 WebMarkupContainer editorArea=new WebMarkupContainer(editorArea);
 String text=editorArea.getMarkup().toString(true)

 But this don't give me the updated HTML content. I give only the
 initial html content. what is the problem here?

 Thanks!

 --
 Regards
 Andun S.L. Gunawardana
 Undergraduate
 Department of Computer Science And Engineering
 University of Moratuwa
 Sri Lanka

 Blog - http://www.insightforfuture.blogspot.com/
 LinkedIn -
   http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
 Twitter -http://twitter.com/AndunSLG


 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org


   
  
  
  
   --
   WBR
   Maxim aka solomax
  
 



 --
 WBR
 Maxim aka solomax




-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG


How I get the internal html content of a dynamically updated div tag using Apache Wicket

2013-05-31 Thread Andun Sameera
Hi,

In my html file I have a div tag like this,

div wicket:id=editorAreaType Here/div

I am using a JavaScript library called bootstrap-wysiwyg to make this
div tag a text are which we can type rich text. When the person types
text, div tag's html content updates to represent the text content in
html. I want to retrieve it in to the Java code of the html file in
wicket. I tried to do it by creating reference variable to div tag
like following,

WebMarkupContainer editorArea=new WebMarkupContainer(editorArea);
String text=editorArea.getMarkup().toString(true)

But this don't give me the updated HTML content. I give only the
initial html content. what is the problem here?

Thanks!

-- 
Regards
Andun S.L. Gunawardana
Undergraduate
Department of Computer Science And Engineering
University of Moratuwa
Sri Lanka

Blog - http://www.insightforfuture.blogspot.com/
LinkedIn - http://www.linkedin.com/pub/andun-s-l-gunawardana/34/646/703
Twitter -http://twitter.com/AndunSLG

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org