RE: How to fail validation if ListMultipleChoice is empty

2011-05-02 Thread Coleman, Chris
That was my plan exactly but I didn't know of a way to tell which button was 
doing the form submission until now!

Thanks for that Form#findSubmittingButton works beautifully!

I don't even think it's a hack as that validation should only really a problem 
if the user is submitting the form, not when they are merely adding items to 
the list.

We are using models for the storage of which items are in the list when the 
user clicks OK.
We are also using models to keep track of which items the user has selected 
(multiple selection is turned on).

The form is a classic 'tranfer' setup - with 2 list boxes and 2 buttons 
add/remove. The user can transfer items from one list to the other.

-Original Message-
From: Clint Checketts [mailto:checke...@gmail.com] 
Sent: Monday, 2 May 2011 3:40 PM
To: users@wicket.apache.org
Subject: Re: How to fail validation if ListMultipleChoice is empty

Good catch on AjaxSubmitButton being deprecated, I guess an IDe would have
made that obvious ;)

I do have to say using the getChoices over a proper model may give you more
work than needed in updating the underlying model objects (maybe consider
overriding the getConvertedInput to return getChoices)

It sounds like you have different buttons for adding and submitting. Correct
me if this is too hackish, but you could change the validator to check if
the addBtn is the submitting button, and ignore the validation in that case:

  form.add(new AbstractFormValidator()
  {
public FormComponent[] getDependentFormComponents()
{
  return null;
}

public void validate(Form? form)
{
  List sets = targettedSetsList.getChoices();

  if ((*!addBtn.equals(form.findSubmittingButton()) * sets.size() == 0
) {
targettedSetsList.error((IValidationError)new
  ValidationError().addMessageKey(error.noSetSpecified));
  }
}
  });


-Clint

On Mon, May 2, 2011 at 12:27 AM, Coleman, Chris 
chris.cole...@thalesgroup.com.au wrote:

 According to the doco the default form processing behavior is executed for
 AjaxButton and AjaxSubmitButton (in fact AjaxSubmitButton appears to be
 deprecated - behaves the same as AjaxButton anyway?).

 I am using AjaxButton.

 I actually don't care about the selections but rather, the entries that the
 user has added to the list (whether selected or not) which is why I call
 getChoices() rather than getConvertedInput()

 The button code is:

  AjaxButton addBtn = new AjaxButton(add) {
@Override
protected void onSubmit(AjaxRequestTarget target, Form form) {
  update(target, selectedAvailableSets, availableSetsList,
 targettedSetsList);
}

@Override
protected void onError(AjaxRequestTarget target, Form form) {
}
  };

  addBtn.setOutputMarkupId(true);

  add(addBtn);


 -Original Message-
 From: Clint Checketts [mailto:checke...@gmail.com]
 Sent: Monday, 2 May 2011 2:28 PM
 To: users@wicket.apache.org
 Subject: Re: How to fail validation if ListMultipleChoice is empty

 You are correct that the Form's validation should only fire when submitting
 the form. When an individual element is updated via ajax (as in an
 AjaxFormComponentUpdatingBehavior) then just the processing and validations
 steps are fired for the individual form component.

 It makes me wonder if you are using an AjaxSubmitButton instead of just an
 AjaxButton. (Or similarly an AjaxSubmitLink instead of an  AjaxLink) Mind
 including your button's code?

 Also, why are you calling getChoices() instead of getConvertedInput() in
 the
 validator? Choices represent the possible selection options, the converted
 input is the value of the selected choices.

 -Clint

 On Sun, May 1, 2011 at 9:25 PM, Coleman, Chris 
 chris.cole...@thalesgroup.com.au wrote:

  Yes, it's all via AJAX.
 
  In the last few minutes I've tried a different approach and it works ok
 but
  it introduces another problem:
 
   form.add(new AbstractFormValidator()
   {
 public FormComponent[] getDependentFormComponents()
 {
   return null;
 }
 
 public void validate(Form? form)
 {
   List sets = targettedSetsList.getChoices();
 
   if ( sets.size() == 0 ) {
 targettedSetsList.error((IValidationError)new
  ValidationError().addMessageKey(error.noSetSpecified));
   }
 }
   });
 
  This accurately detects when nothing is in the list and displays an error
  message but once emptied we can not add new elements to the list because
 the
  validation is also executed when the 'add' button is pressed. The
 validation
  fails because the list is empty so the 'add' fails, making it impossible
 to
  add new elements when the list is empty.
 
  I thought validation would only occur when the user submits the form but
 it
  appears to be fired off whenever the user presses the 'add' button. Is
 this
  to be expected?
 
 
  -Original Message-
  From: Clint Checketts [mailto:checke...@gmail.com]
  Sent: Monday, 2 May 2011 12:10 PM
  To: users@wicket.apache.org
  

wicket extensions - Palette Problem

2011-05-02 Thread bremy
Hi I'm using wicket extensions 1.4.17. 
I came across a problem with adding selection on Palette. 

... 
.. 
add(form); 

ListString available = new ArrayListString(); 
original.add(A); 
original.add(B); 
original.add(C); 
original.add(D); 
original.add(E); 

PaletteString palette = new PaletteString(palette, new
ListModelString(available.subList(1,2)), 
new CollectionModelString(available), new
ChoiceRenderer(), 10, false); 
form.add(palette); 

selection list is sublist of available but this only displays 

A on the selected list and nothing on available list. 

Any help will be appreciated. 

Thanks!--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicket-extensions-Palette-Problem-tp3489257p3489257.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: wicket extensions - Palette Problem

2011-05-02 Thread Andrea Del Bene
The same using wicket 1.5 snapshot. I'm debugging the class searching 
for a solution.

Hi I'm using wicket extensions 1.4.17.
I came across a problem with adding selection on Palette.

...
..
add(form);

ListString  available = new ArrayListString();
original.add(A);
original.add(B);
original.add(C);
original.add(D);
original.add(E);

PaletteString  palette = new PaletteString(palette, new
ListModelString(available.subList(1,2)),
 new CollectionModelString(available), new
ChoiceRenderer(), 10, false);
form.add(palette);

selection list is sublist of available but this only displays

A on the selected list and nothing on available list.

Any help will be appreciated.

Thanks!--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicket-extensions-Palette-Problem-tp3489257p3489257.html
Sent from the Users forum mailing list archive at Nabble.com.

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






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



Re: Ajaxifying existing application

2011-05-02 Thread splitshade
It´s not as if I have a choice, whether this requirement should be
implemented or not:(...

I´m not a big ajax fan, i like the application the way it is today, but ajax
is hype today, 
and every customer wants more of it...

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Ajaxifying-existing-application-tp3486615p3489746.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Problem using dynamic select with optgroups and Firefox

2011-05-02 Thread rawe
see solution in
http://apache-wicket.1842946.n4.nabble.com/Dynamic-Select-and-SelectOptions-tp1872483p3310381.html

It's also working with firefox. My problem before was just a javascript
failure.

greetings

Ralph

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Problem-using-dynamic-select-with-optgroups-and-Firefox-tp3310846p3489766.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: DataTable's view does not always update

2011-05-02 Thread James Carman
Try changing it to a servlet.  There's another thread going on here
just recently which gives an example.

On Sun, May 1, 2011 at 10:22 PM, D D dawi...@gmail.com wrote:
 I have a filter in web.xml file - however I did not set it up. At the
 same time I've started to question the setup because I tried to deploy
 a clean test app (by clean I mean new ear file for the test app and
 no extra ear files and configuration - just a strip down example from
 wicket's website) and I'm getting 404 trying to bring the application
 up.

 So the original application with problem is having 404 on ajax calls
 but it will start up. Test app will not start up - shows 404 all the
 time.

 Is it a WAS setup issue?

 Thanks,
 Dave


 On Sun, May 1, 2011 at 8:57 PM, James Carman ja...@carmanconsulting.com 
 wrote:
 You are using a servlet instead of a filter, right?  I don't see the
 entire conversation in my gmail, here, so I hope I didn't miss
 something.

 On Sun, May 1, 2011 at 9:51 PM, D D dawi...@gmail.com wrote:
 I tried the setting with true and false settings. It still doesn't work.

 Here is Ajax Debug
 INFO: Initiating Ajax GET request on
 ?wicket:interface=:0:dataForm:dataPanel:rxEntryTabs:panel:link::IBehaviorListener:0:-1random=0.6781234819490185
 INFO: Invoking pre-call handler(s)...
 ERROR: Received Ajax response with code: 404
 INFO: Invoking post-call handler(s)...
 INFO: Invoking failure handler(s)...
 INFO: focus removed from link30


 I also traced through debug the response sent to HttpResponse object
 and it's what I'm expecting:

 “?xml version=1.0 encoding=UTF-8?ajax-responsecomponent
 id=counter31 ![CDATA[span id=counter315/span]]/component
 /ajax-response”

 Not only it's written but the response object is properly closed too.
 Not a single exception is thrown in Wicket's code.

 The problem has to be somewhere inside WAS processing, right?

 Any ideas where?

 Dave

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



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



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



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



Re: wicket extensions - Palette Problem

2011-05-02 Thread Andrea Del Bene

Ok, I think I got it.
You should add to choice render an empty id and value expression, i.e. 
new ChoiceRenderer(, ). Without any expression any choices is 
recognized as selected.

Hi I'm using wicket extensions 1.4.17.
I came across a problem with adding selection on Palette.

...
..
add(form);

ListString  available = new ArrayListString();
original.add(A);
original.add(B);
original.add(C);
original.add(D);
original.add(E);

PaletteString  palette = new PaletteString(palette, new
ListModelString(available.subList(1,2)),
 new CollectionModelString(available), new
ChoiceRenderer(), 10, false);
form.add(palette);

selection list is sublist of available but this only displays

A on the selected list and nothing on available list.

Any help will be appreciated.

Thanks!--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicket-extensions-Palette-Problem-tp3489257p3489257.html
Sent from the Users forum mailing list archive at Nabble.com.

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






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



Re: POST path via Ajax erratically invalid when used with #

2011-05-02 Thread Jeremy Levy
It happens consistently in Chrome and the fix is to clear cookies /
JSESSIONID... Can you be more specific in the javascript where the relative
path is assembled I can't find it... ?

On Fri, Apr 29, 2011 at 3:10 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 See wicketSubmitFormById() and wicketAjaxPost() in wicket-ajax.js

 On Fri, Apr 29, 2011 at 12:59 AM, Jeremy Levy jel...@gmail.com wrote:
  I've noticed that in 1.4.17 in some circumstances when using Wicket to
 POST
  data over AJAX the path it's POSTing to tries to include the value after
 #
  in the URL.
 
  For example on a page with a URL like http://foo.bar/MyPage#oneWicket-Ajax
  attempts to POST to http://foo.bar/MyPageone.
 
  I'm having trouble using the debugger to nail down where in the JS this
 is
  happening, can someone help point me to the function?
 
  Jeremy
 
  --
  Jeremy Levy
 



 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




-- 
Jeremy Levy


Re: POST path via Ajax erratically invalid when used with #

2011-05-02 Thread Martin Grigorov
I am not aware of any logic in wicket-ajax.js which changes the url
passed from the server side.
See 
org.apache.wicket.ajax.AjaxEventBehavior.generateCallbackScript(CharSequence)

I gave you the names of the JavaScript functions which trigger the
form submit. Use Chrome Developer Tools to debug the JavaScript and
see where the url gets broken.

On Mon, May 2, 2011 at 2:26 PM, Jeremy Levy jel...@gmail.com wrote:
 It happens consistently in Chrome and the fix is to clear cookies /
 JSESSIONID... Can you be more specific in the javascript where the relative
 path is assembled I can't find it... ?

 On Fri, Apr 29, 2011 at 3:10 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 See wicketSubmitFormById() and wicketAjaxPost() in wicket-ajax.js

 On Fri, Apr 29, 2011 at 12:59 AM, Jeremy Levy jel...@gmail.com wrote:
  I've noticed that in 1.4.17 in some circumstances when using Wicket to
 POST
  data over AJAX the path it's POSTing to tries to include the value after
 #
  in the URL.
 
  For example on a page with a URL like http://foo.bar/MyPage#oneWicket-Ajax
  attempts to POST to http://foo.bar/MyPageone.
 
  I'm having trouble using the debugger to nail down where in the JS this
 is
  happening, can someone help point me to the function?
 
  Jeremy
 
  --
  Jeremy Levy
 



 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




 --
 Jeremy Levy




-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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



DataView - AjaxFallBackLink works only when outside DataView Link is once called

2011-05-02 Thread devush
Hi,

 I have one link within the DataView and one directly attached to the
Panel. The link within the DataView is added to the item within the
populateItem() method.  This links gives me error when called *when*
the page is created:

WicketMessage: org.apache.wicket.WicketRuntimeException: component
events:dc:events:1:f:show_lk not found on page mypage[id = 2],
listener interface = [RequestListenerInterface name=IBehaviorListener,
method=public abstract void
org.apache.wicket.behavior.IBehaviorListener.onRequest()]

But, when I click another AjaxFallbackLink which is outside the
DataView then the link within the DataView starts working. I should be
calling something good in the link which is directly on the Panel.
Code of the AjaxFallbackLink#onClick outside the DataView is:
AjaxFallbackLink sort2_lk = new AjaxFallbackLink(sort2_lk) {
public void onClick(AjaxRequestTarget target) { 
   dataContainer.remove(events);
DataView dataView = createEventsDataView(list);
dataContainer.add(dataView);
target.addComponent(dataContainer);
}
};
dataContainer.add(sort2_lk);

Dataview is added to the panel using:
 final WebMarkupContainer dataContainer = new
WebMarkupContainer(dc);
dataContainer.setOutputMarkupId(true);
dataContainer.setOutputMarkupPlaceholderTag(true);
 

DataView dataView = createEventsDataView(basicCommentWebs);
dataContainer.add(dataView);
dataContainer.add(setNavigator(dataContainer, dataView));
add(dataContainer);


private DataView createEventsDataView(ListBasicCommentWeb list) {
final DataView dv = new DataView(events, new ListDataProvider(
list)) {
@Override
protected void populateItem(final Item item) {
 ...
   Form f = new Form(f);
AjaxFallbackLink hide_lk = new
AjaxFallbackLink(show_lk) {
@Override
public void onClick(AjaxRequestTarget 
target) {
System.out.println(\n Hide on 
onClick);
//mcp.setVisible(false);
//target.addComponent(mcp);
}
};
f.add(show_lk);
   }

I have added setOutputMarkupId(true) and
setOutputMarkupPlaceholderTag(true) on the Form and links also, but
results are still the same.

What i am doing special in the case of AjaxFallBackLink which is
attached directly to the Panel?
thanks
devush

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



Re: DataTable's view does not always update

2011-05-02 Thread D D
FYI. I added the index.htm file to my project and everything now
works. This is very strange and if anyone has an insight why this
helped I would be very glad to read about it.

Since I didn't try switching to servlet I'm not sure if that would
have helped as well.

Thank you for all of your suggestions!

Dave

On Mon, May 2, 2011 at 6:18 AM, James Carman ja...@carmanconsulting.com wrote:
 Try changing it to a servlet.  There's another thread going on here
 just recently which gives an example.

 On Sun, May 1, 2011 at 10:22 PM, D D dawi...@gmail.com wrote:
 I have a filter in web.xml file - however I did not set it up. At the
 same time I've started to question the setup because I tried to deploy
 a clean test app (by clean I mean new ear file for the test app and
 no extra ear files and configuration - just a strip down example from
 wicket's website) and I'm getting 404 trying to bring the application
 up.

 So the original application with problem is having 404 on ajax calls
 but it will start up. Test app will not start up - shows 404 all the
 time.

 Is it a WAS setup issue?

 Thanks,
 Dave


 On Sun, May 1, 2011 at 8:57 PM, James Carman ja...@carmanconsulting.com 
 wrote:
 You are using a servlet instead of a filter, right?  I don't see the
 entire conversation in my gmail, here, so I hope I didn't miss
 something.

 On Sun, May 1, 2011 at 9:51 PM, D D dawi...@gmail.com wrote:
 I tried the setting with true and false settings. It still doesn't work.

 Here is Ajax Debug
 INFO: Initiating Ajax GET request on
 ?wicket:interface=:0:dataForm:dataPanel:rxEntryTabs:panel:link::IBehaviorListener:0:-1random=0.6781234819490185
 INFO: Invoking pre-call handler(s)...
 ERROR: Received Ajax response with code: 404
 INFO: Invoking post-call handler(s)...
 INFO: Invoking failure handler(s)...
 INFO: focus removed from link30


 I also traced through debug the response sent to HttpResponse object
 and it's what I'm expecting:

 “?xml version=1.0 encoding=UTF-8?ajax-responsecomponent
 id=counter31 ![CDATA[span id=counter315/span]]/component
 /ajax-response”

 Not only it's written but the response object is properly closed too.
 Not a single exception is thrown in Wicket's code.

 The problem has to be somewhere inside WAS processing, right?

 Any ideas where?

 Dave

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



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



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



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



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



wicket facebook application

2011-05-02 Thread Josh Kamau
I am doing a facebook application in wicket. To get facebook authentication
token, I have written a wicket filter as below:



package com.mycompany.myapp.config;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.visural.common.StringUtil;

public class FBOAuth implements Filter {
public void init(FilterConfig fc) throws ServletException {
}

public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain
fc)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) sr;
HttpServletResponse res = (HttpServletResponse) sr1;
res.sendRedirect(FaceBook.getLoginRedirectURL());
String code = sr.getParameter(code);
if (StringUtil.isNotBlankStr(code)) {
String authURL = FaceBook.getAuthURL(code);
URL url = new URL(authURL);
try {
String result = readURL(url);
String accessToken = null;
Integer expires = null;
String[] pairs = result.split();
for (String pair : pairs) {
String[] kv = pair.split(=);
if (kv.length != 2) {
throw new RuntimeException(Unexpected auth
response);
} else {
if (kv[0].equals(access_token)) {
accessToken = kv[1];
}
if (kv[0].equals(expires)) {
expires = Integer.valueOf(kv[1]);
}
}
}
if (accessToken != null  expires != null)
{
HttpSession ses = req.getSession();
ses.setAttribute(authToken, accessToken);


} else {
throw new RuntimeException(
Access token and expires not found);
}
} catch (IOException e) {
throw new RuntimeException(e);
}

}
}
private String readURL(URL url) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
InputStream is = url.openStream();
int r;
while ((r = is.read()) != -1) {
baos.write(r);
}
return new String(baos.toByteArray());
}

public void destroy() {
}
}





In the doFilter method, I have done all the redirects required and gotten
the authentication token(accesstoken). At this point, I store the value as
an attribute to the httpSession which i have gotten by
ServleteRequest.getSession();

I want to acess this token in a wicket page class so that I use RestFB to
create a FaceBook Client etc. This is what I have done in the wicket page
class:

HttpSession session = null;

if (RequestCycle.get()!= null)
session = ((WebRequest) RequestCycle.get().getRequest())
.getHttpServletRequest().getSession();

if (session != null) {

System.out.print(# AuthToken: 
+ session.getAttribute(authToken));

}


However, this is the output I get and I am totally stuck:

# AuthToken: null


Where am i going wrong?


Re: wicket facebook application

2011-05-02 Thread Peter Karich
 Why not doing this directly the wicket-way with PageParameters and your
own Session?

FBPage(PageParameters params) {
   // do something with: params.getString(xy);

   // construct a new MySession object within the WicketApp.init method:
   // @Override Session newSession(Request request, Response response) {
   //   return new MySession(request); }

   // No need for complicated stuff just call 'getSession()' and get or
set the token:
   MySession session = (MySession)getSession();
   // session.getToken();
}

I've done similar things in jetwick for twitter authentication.

Regards,
Peter.



-- 
http://jetwick.com open twitter search


 I am doing a facebook application in wicket. To get facebook authentication
 token, I have written a wicket filter as below:



 package com.mycompany.myapp.config;

 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;

 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletException;
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;

 import com.visural.common.StringUtil;

 public class FBOAuth implements Filter {
 public void init(FilterConfig fc) throws ServletException {
 }

 public void doFilter(ServletRequest sr, ServletResponse sr1, FilterChain
 fc)
 throws IOException, ServletException {
 HttpServletRequest req = (HttpServletRequest) sr;
 HttpServletResponse res = (HttpServletResponse) sr1;
 res.sendRedirect(FaceBook.getLoginRedirectURL());
 String code = sr.getParameter(code);
 if (StringUtil.isNotBlankStr(code)) {
 String authURL = FaceBook.getAuthURL(code);
 URL url = new URL(authURL);
 try {
 String result = readURL(url);
 String accessToken = null;
 Integer expires = null;
 String[] pairs = result.split();
 for (String pair : pairs) {
 String[] kv = pair.split(=);
 if (kv.length != 2) {
 throw new RuntimeException(Unexpected auth
 response);
 } else {
 if (kv[0].equals(access_token)) {
 accessToken = kv[1];
 }
 if (kv[0].equals(expires)) {
 expires = Integer.valueOf(kv[1]);
 }
 }
 }
 if (accessToken != null  expires != null)
 {
 HttpSession ses = req.getSession();
 ses.setAttribute(authToken, accessToken);


 } else {
 throw new RuntimeException(
 Access token and expires not found);
 }
 } catch (IOException e) {
 throw new RuntimeException(e);
 }

 }
 }
 private String readURL(URL url) throws IOException {
 ByteArrayOutputStream baos = new ByteArrayOutputStream();
 InputStream is = url.openStream();
 int r;
 while ((r = is.read()) != -1) {
 baos.write(r);
 }
 return new String(baos.toByteArray());
 }

 public void destroy() {
 }
 }





 In the doFilter method, I have done all the redirects required and gotten
 the authentication token(accesstoken). At this point, I store the value as
 an attribute to the httpSession which i have gotten by
 ServleteRequest.getSession();

 I want to acess this token in a wicket page class so that I use RestFB to
 create a FaceBook Client etc. This is what I have done in the wicket page
 class:

 HttpSession session = null;

 if (RequestCycle.get()!= null)
 session = ((WebRequest) RequestCycle.get().getRequest())
 .getHttpServletRequest().getSession();

 if (session != null) {

 System.out.print(# AuthToken: 
 + session.getAttribute(authToken));

 }


 However, this is the output I get and I am totally stuck:

 # AuthToken: null


 Where am i going wrong?



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



Submit non-wicket form through wicket form

2011-05-02 Thread Alec Swan
Hello,

We have an interesting situation here. We have a Wicket page which we
deliver to our web designer. The web designer uses this page as a
template to build many pages and on each page may or may not choose to
add a non-wicket form. Our webapp should collect the names and values
submitted from this form and store them in a CSV file.

So, the question is how to provide the web designer the flexibility of
adding a random form and being able to collect this form submission
data on the back-end?

One idea that I am currently working on is this.
1. Add an empty Wicket form to the the wicket template page;
2. Provide submitCustomForm() JavaScript method that web designer will
call from his custom form's action;
3. In submitCustomForm() we can:
3.1 either change the custom form's action to point to Wicket
form's action and submit custom form.
3.2. or somehow copy form elements from custom form to wicket form
and submit wicket form.

Your feedback will be greatly appreciated.

Thanks,

Alec

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



Re: Submit non-wicket form through wicket form

2011-05-02 Thread Igor Vaynberg
or you can write a servlet to process form submissions from all these
different forms and call it a day.

-igor

On Mon, May 2, 2011 at 9:21 AM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 We have an interesting situation here. We have a Wicket page which we
 deliver to our web designer. The web designer uses this page as a
 template to build many pages and on each page may or may not choose to
 add a non-wicket form. Our webapp should collect the names and values
 submitted from this form and store them in a CSV file.

 So, the question is how to provide the web designer the flexibility of
 adding a random form and being able to collect this form submission
 data on the back-end?

 One idea that I am currently working on is this.
 1. Add an empty Wicket form to the the wicket template page;
 2. Provide submitCustomForm() JavaScript method that web designer will
 call from his custom form's action;
 3. In submitCustomForm() we can:
    3.1 either change the custom form's action to point to Wicket
 form's action and submit custom form.
    3.2. or somehow copy form elements from custom form to wicket form
 and submit wicket form.

 Your feedback will be greatly appreciated.

 Thanks,

 Alec

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



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



Re: Submit non-wicket form through wicket form

2011-05-02 Thread Alec Swan
Igor, we would like have access to the Wicket page model while
processing the custom form submission, so using separate servlets is
not a good solution for us.

I started implemented the 3.1 step in our solution and immediately ran
into a problem because wicket form contains a DIV with a hidden input
with name wicketForm9a_hf_0, which I suspect is required by Wicket. I
am assuming that 3.2 is a preferred approach because it will work even
if other hidden form elements are added in later versions of Wicket.

Thoughts?

Thanks,

Alec

On Mon, May 2, 2011 at 10:44 AM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 or you can write a servlet to process form submissions from all these
 different forms and call it a day.

 -igor

 On Mon, May 2, 2011 at 9:21 AM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 We have an interesting situation here. We have a Wicket page which we
 deliver to our web designer. The web designer uses this page as a
 template to build many pages and on each page may or may not choose to
 add a non-wicket form. Our webapp should collect the names and values
 submitted from this form and store them in a CSV file.

 So, the question is how to provide the web designer the flexibility of
 adding a random form and being able to collect this form submission
 data on the back-end?

 One idea that I am currently working on is this.
 1. Add an empty Wicket form to the the wicket template page;
 2. Provide submitCustomForm() JavaScript method that web designer will
 call from his custom form's action;
 3. In submitCustomForm() we can:
    3.1 either change the custom form's action to point to Wicket
 form's action and submit custom form.
    3.2. or somehow copy form elements from custom form to wicket form
 and submit wicket form.

 Your feedback will be greatly appreciated.

 Thanks,

 Alec

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



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



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



Re: POST path via Ajax erratically invalid when used with #

2011-05-02 Thread Jeremy Levy
Thanks for the reply, as I already mentioned I've tried running this in the
debugger in Chrome but it's not clear to me where the HOST part of the URL
is being generated all I see is the path.

The full URL that is getting posted to is:

http://mobile/MyPagescreen-two?x=1cBpJXjtIYZljhKs29abIqj8*YDCtKbjg*TV2waFYQRLE*9vNYy87LLwY1SctZ0Ck8iPyZttk0qfiInaa9kSd98b1moKXZbN-yjDEBXqdDnU4WkRPLW5AArandom=0.7044208080042154http://mobile/webkitregscreen-two?x=1cBpJXjtIYZljhKs29abIqj8*YDCtKbjg*TV2waFYQRLE*9vNYy87LLwY1SctZ0Ck8iPyZttk0qfiInaa9kSd98b1moKXZbN-yjDEBXqdDnU4WkRPLW5AArandom=0.7044208080042154

The mount is actually just /MyPage 'screen-two' is the value after the #,
the URL in the browser looks like http://mobile/MyPage#screen-two.

As you suggested I also tried
debugging 
org.apache.wicket.ajax.AjaxEventBehavior.generateCallbackScript(CharSequence),
but from what I can tell that generates the relative URL to POST to.
Ex: var
wcall=wicketAjaxPost('?x=3NGhze8Hqqc*UOnOuxCljvnljwk0iN2tSqud8EMVbEweya7HhUn*6fgOmnCv6OwW',
wicketSerialize(Wicket.$('username101')),function() {
}.bind(this),function() { }.bind(this), function() {return
Wicket.$('username101') != null;}.bind(this));

From debugging the javascript, best I can follow is that the actual POST is
made at line 938: t.send(body);

However, looking at all the objects until that point still only describes
the url as ?x=
3NGhze8Hqqc*UOnOuxCljvnljwk0iN2tSqud8EMVbEweya7HhUn*6fgOmnCv6OwW.

What's interesting is that clearing the session seems to fix the problem
until I try it a second time.  It's also worthwhile to note that if I load
the page and include '/' at the end of the URL it works perfectly,
repeatedly.

It's still not clear to me where the http://xxx/xxx or BaseURL comes from in
the wicket JS, is that a function of XMLHttpRequest?  location.href
references the correct Host..

Any ideas or insights?





On Mon, May 2, 2011 at 8:32 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 I am not aware of any logic in wicket-ajax.js which changes the url
 passed from the server side.
 See
 org.apache.wicket.ajax.AjaxEventBehavior.generateCallbackScript(CharSequence)

 I gave you the names of the JavaScript functions which trigger the
 form submit. Use Chrome Developer Tools to debug the JavaScript and
 see where the url gets broken.

 On Mon, May 2, 2011 at 2:26 PM, Jeremy Levy jel...@gmail.com wrote:
  It happens consistently in Chrome and the fix is to clear cookies /
  JSESSIONID... Can you be more specific in the javascript where the
 relative
  path is assembled I can't find it... ?
 
  On Fri, Apr 29, 2011 at 3:10 AM, Martin Grigorov mgrigo...@apache.org
 wrote:
 
  See wicketSubmitFormById() and wicketAjaxPost() in wicket-ajax.js
 
  On Fri, Apr 29, 2011 at 12:59 AM, Jeremy Levy jel...@gmail.com wrote:
   I've noticed that in 1.4.17 in some circumstances when using Wicket to
  POST
   data over AJAX the path it's POSTing to tries to include the value
 after
  #
   in the URL.
  
   For example on a page with a URL like
 http://foo.bar/MyPage#oneWicket-Ajax
   attempts to POST to http://foo.bar/MyPageone.
  
   I'm having trouble using the debugger to nail down where in the JS
 this
  is
   happening, can someone help point me to the function?
  
   Jeremy
  
   --
   Jeremy Levy
  
 
 
 
  --
  Martin Grigorov
  jWeekend
  Training, Consulting, Development
  http://jWeekend.com
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 
  --
  Jeremy Levy
 



 --
 Martin Grigorov
 jWeekend
 Training, Consulting, Development
 http://jWeekend.com

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




-- 
Jeremy Levy


Re: Submit non-wicket form through wicket form

2011-05-02 Thread Clint Checketts
You could direct the non-wicket form's action to direct to a page and use the 
PageParameter's object to parse the input.

I did that for a while until I finally learned how to use Wicket forms the 
right way. It worked quite well.

You can parse in the values, manually checking validity (even manually running 
validators if you like) and still log your own feedback messages.

-Clint 
-- 
Clint Checketts
Sent with Sparrow
On Monday, May 2, 2011 at 1:47 PM, Alec Swan wrote: 
 Igor, we would like have access to the Wicket page model while
 processing the custom form submission, so using separate servlets is
 not a good solution for us.
 
 I started implemented the 3.1 step in our solution and immediately ran
 into a problem because wicket form contains a DIV with a hidden input
 with name wicketForm9a_hf_0, which I suspect is required by Wicket. I
 am assuming that 3.2 is a preferred approach because it will work even
 if other hidden form elements are added in later versions of Wicket.
 
 Thoughts?
 
 Thanks,
 
 Alec
 
 On Mon, May 2, 2011 at 10:44 AM, Igor Vaynberg igor.vaynb...@gmail.com 
 wrote:
  or you can write a servlet to process form submissions from all these
  different forms and call it a day.
  
  -igor
  
  On Mon, May 2, 2011 at 9:21 AM, Alec Swan alecs...@gmail.com wrote:
   Hello,
   
   We have an interesting situation here. We have a Wicket page which we
   deliver to our web designer. The web designer uses this page as a
   template to build many pages and on each page may or may not choose to
   add a non-wicket form. Our webapp should collect the names and values
   submitted from this form and store them in a CSV file.
   
   So, the question is how to provide the web designer the flexibility of
   adding a random form and being able to collect this form submission
   data on the back-end?
   
   One idea that I am currently working on is this.
   1. Add an empty Wicket form to the the wicket template page;
   2. Provide submitCustomForm() JavaScript method that web designer will
   call from his custom form's action;
   3. In submitCustomForm() we can:
   3.1 either change the custom form's action to point to Wicket
   form's action and submit custom form.
   3.2. or somehow copy form elements from custom form to wicket form
   and submit wicket form.
   
   Your feedback will be greatly appreciated.
   
   Thanks,
   
   Alec
   
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 


Re: DataTable's view does not always update

2011-05-02 Thread Clint Checketts
The reason for the 404 is the Websphere is checking for a file, then
intending to filter before and after serving up the file. Since it finds no
file to serve, it returns the 404.

-Clint

On Mon, May 2, 2011 at 9:33 AM, D D dawi...@gmail.com wrote:

 FYI. I added the index.htm file to my project and everything now
 works. This is very strange and if anyone has an insight why this
 helped I would be very glad to read about it.

 Since I didn't try switching to servlet I'm not sure if that would
 have helped as well.

 Thank you for all of your suggestions!

 Dave

 On Mon, May 2, 2011 at 6:18 AM, James Carman ja...@carmanconsulting.com
 wrote:
  Try changing it to a servlet.  There's another thread going on here
  just recently which gives an example.
 
  On Sun, May 1, 2011 at 10:22 PM, D D dawi...@gmail.com wrote:
  I have a filter in web.xml file - however I did not set it up. At the
  same time I've started to question the setup because I tried to deploy
  a clean test app (by clean I mean new ear file for the test app and
  no extra ear files and configuration - just a strip down example from
  wicket's website) and I'm getting 404 trying to bring the application
  up.
 
  So the original application with problem is having 404 on ajax calls
  but it will start up. Test app will not start up - shows 404 all the
  time.
 
  Is it a WAS setup issue?
 
  Thanks,
  Dave
 
 
  On Sun, May 1, 2011 at 8:57 PM, James Carman 
 ja...@carmanconsulting.com wrote:
  You are using a servlet instead of a filter, right?  I don't see the
  entire conversation in my gmail, here, so I hope I didn't miss
  something.
 
  On Sun, May 1, 2011 at 9:51 PM, D D dawi...@gmail.com wrote:
  I tried the setting with true and false settings. It still doesn't
 work.
 
  Here is Ajax Debug
  INFO: Initiating Ajax GET request on
 
 ?wicket:interface=:0:dataForm:dataPanel:rxEntryTabs:panel:link::IBehaviorListener:0:-1random=0.6781234819490185
  INFO: Invoking pre-call handler(s)...
  ERROR: Received Ajax response with code: 404
  INFO: Invoking post-call handler(s)...
  INFO: Invoking failure handler(s)...
  INFO: focus removed from link30
 
 
  I also traced through debug the response sent to HttpResponse object
  and it's what I'm expecting:
 
  “?xml version=1.0 encoding=UTF-8?ajax-responsecomponent
  id=counter31 ![CDATA[span id=counter315/span]]/component
  /ajax-response”
 
  Not only it's written but the response object is properly closed too.
  Not a single exception is thrown in Wicket's code.
 
  The problem has to be somewhere inside WAS processing, right?
 
  Any ideas where?
 
  Dave
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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




Re: Submit non-wicket form through wicket form

2011-05-02 Thread Igor Vaynberg
an alternative would be to write your own form-like component. form
impl doesnt use any internal hooks that you dont have access to, so
its feasible you can easily write your own version that processes
dynamic fields, etc.

-igor


On Mon, May 2, 2011 at 11:47 AM, Alec Swan alecs...@gmail.com wrote:
 Igor, we would like have access to the Wicket page model while
 processing the custom form submission, so using separate servlets is
 not a good solution for us.

 I started implemented the 3.1 step in our solution and immediately ran
 into a problem because wicket form contains a DIV with a hidden input
 with name wicketForm9a_hf_0, which I suspect is required by Wicket. I
 am assuming that 3.2 is a preferred approach because it will work even
 if other hidden form elements are added in later versions of Wicket.

 Thoughts?

 Thanks,

 Alec

 On Mon, May 2, 2011 at 10:44 AM, Igor Vaynberg igor.vaynb...@gmail.com 
 wrote:
 or you can write a servlet to process form submissions from all these
 different forms and call it a day.

 -igor

 On Mon, May 2, 2011 at 9:21 AM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 We have an interesting situation here. We have a Wicket page which we
 deliver to our web designer. The web designer uses this page as a
 template to build many pages and on each page may or may not choose to
 add a non-wicket form. Our webapp should collect the names and values
 submitted from this form and store them in a CSV file.

 So, the question is how to provide the web designer the flexibility of
 adding a random form and being able to collect this form submission
 data on the back-end?

 One idea that I am currently working on is this.
 1. Add an empty Wicket form to the the wicket template page;
 2. Provide submitCustomForm() JavaScript method that web designer will
 call from his custom form's action;
 3. In submitCustomForm() we can:
    3.1 either change the custom form's action to point to Wicket
 form's action and submit custom form.
    3.2. or somehow copy form elements from custom form to wicket form
 and submit wicket form.

 Your feedback will be greatly appreciated.

 Thanks,

 Alec

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



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



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



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



Re: Submit non-wicket form through wicket form

2011-05-02 Thread Alec Swan
I ended up adding an empty Wicket form to my base page and creating
submitCustomForm() JavaScript function which can be called from any
non-Wicket form submission. The function copies all form elements from
the form being submitted to the Wicket form and submits the Wicket
form. Works like a charm.

Thanks,

Alec

On Mon, May 2, 2011 at 10:22 PM, Igor Vaynberg igor.vaynb...@gmail.com wrote:
 an alternative would be to write your own form-like component. form
 impl doesnt use any internal hooks that you dont have access to, so
 its feasible you can easily write your own version that processes
 dynamic fields, etc.

 -igor


 On Mon, May 2, 2011 at 11:47 AM, Alec Swan alecs...@gmail.com wrote:
 Igor, we would like have access to the Wicket page model while
 processing the custom form submission, so using separate servlets is
 not a good solution for us.

 I started implemented the 3.1 step in our solution and immediately ran
 into a problem because wicket form contains a DIV with a hidden input
 with name wicketForm9a_hf_0, which I suspect is required by Wicket. I
 am assuming that 3.2 is a preferred approach because it will work even
 if other hidden form elements are added in later versions of Wicket.

 Thoughts?

 Thanks,

 Alec

 On Mon, May 2, 2011 at 10:44 AM, Igor Vaynberg igor.vaynb...@gmail.com 
 wrote:
 or you can write a servlet to process form submissions from all these
 different forms and call it a day.

 -igor

 On Mon, May 2, 2011 at 9:21 AM, Alec Swan alecs...@gmail.com wrote:
 Hello,

 We have an interesting situation here. We have a Wicket page which we
 deliver to our web designer. The web designer uses this page as a
 template to build many pages and on each page may or may not choose to
 add a non-wicket form. Our webapp should collect the names and values
 submitted from this form and store them in a CSV file.

 So, the question is how to provide the web designer the flexibility of
 adding a random form and being able to collect this form submission
 data on the back-end?

 One idea that I am currently working on is this.
 1. Add an empty Wicket form to the the wicket template page;
 2. Provide submitCustomForm() JavaScript method that web designer will
 call from his custom form's action;
 3. In submitCustomForm() we can:
    3.1 either change the custom form's action to point to Wicket
 form's action and submit custom form.
    3.2. or somehow copy form elements from custom form to wicket form
 and submit wicket form.

 Your feedback will be greatly appreciated.

 Thanks,

 Alec

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



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



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



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



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