Re: calling shell script from Wicket java program

2012-02-04 Thread Martin Grigorov
On Fri, Feb 3, 2012 at 5:53 AM, abhisheks sachini...@gmail.com wrote:
 i am developing a web application using apache wickets. I need to call a
 shell script residing on my local disk from java code.

 this is the section of code under concern :

 ProcessBuilder builder = new
 ProcessBuilder(sh,/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh);
                                 builder.redirectErrorStream(true);
                                    final Process process = builder.start();
                        }
                                 process.waitFor();

 --

 This is piece of code successfully runs fine and execute a shell when this
 code is a part of java prgram residing anywhere on my laal disk. However,
 when i make a jar file of a progeam , put in webapps folder , and start the
 web application , it reports permission denied error on test.sh script.

 I then modify the line as :

 ProcessBuilder builder = new ProcessBuilder(sudo, -A,
 sh,/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh);
 and set the SUDO_ASKPASS env variable to script returning my sudo password ,
 then it reports the following error :
 sudo: 3 incorrect password attempts and script calling is failed. Again this
 works correctly when i run the program outside the web development
 environment , it is able to read my sudo password correctly at run time with
 -A option. Why is it failing when running the same program from web
 application ?  please help !!

Maybe your web server runs with a user which has no permissions to
become different user (via sudo).
When you run it as a normal Java program you run it with your user
which has this permission.

In any case it has nothing to do with Wicket.



 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/calling-shell-script-from-Wicket-java-program-tp4353583p4353583.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




-- 
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



Re: Communication (in-vm) between webapps

2012-02-04 Thread Martin Grigorov
On Fri, Feb 3, 2012 at 10:17 PM, Serban.Balamaci thespamtr...@gmail.com wrote:
 Some REST interface to be called through Httpclient from the admin
 application I'd say it's the simplest approach.

I also think this is better than JMX, JMS/RabbitMQ/0mq, ... because
these require different ports to be open and sometimes this is
problematic.


 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Communication-in-vm-between-webapps-tp4355616p4355667.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




-- 
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



Re: ResourceReference for resource in webapp dir

2012-02-04 Thread Martin Grigorov
Hi,

I didn't understand why you want to use ResRef but if this is your
requirement then the easiest will be to create your own IRequestMapper
that handles only your own IRequestHandler that works with your ResRef
impl.
IRequestMapper#mapHandler(IRequestHandler) is the one responsible to
create Url when RequestCycle#urlFor() is used.
Also take a look at
org.apache.wicket.util.string.UrlUtils#rewriteToContextRelative()

On Fri, Feb 3, 2012 at 5:40 PM, Bertrand Guay-Paquet
ber...@step.polymtl.ca wrote:
 Hi,

 I have the following code in my base page:

 public void renderHead(IHeaderResponse response) {
    // scripts/jquery-1.7.1.min.js is in webapp dir
    response.renderJavaScriptReference(scripts/jquery-1.7.1.min.js);
 }

 How can I transform this direct URL to a ResourceReference?

 PackageResourceReference is not a good fit because I don't want to store the
 .js in a Java package since it is used by non-wicket pages.

 With ContextRelativeResource, Wicket reads the actual resource and sends the
 result instead of simply pointing to a URL.

 AbstractResource with its newResourceResponse() abstract method requires to
 return the actual ResourceResponse which won't allow for a simple URL.

 So from what I gather, I would have to fallback to implementing an
 IResource's respond(Attributes attributes) method. I looked at the
 implementation in AbstractResource but I'm confused about what to do with
 headers since I only want a URL.

 So, does this functionality already exist? If not, do you have a few
 pointers to steer me in the right direction?

 Thanks,
 Bertrand

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




-- 
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



Re: Wicket ResourceFinder implementation for resources modified at runtime

2012-02-04 Thread Martin Grigorov
Hi,

On Fri, Feb 3, 2012 at 5:21 PM, Santha Kumar santhakr.t...@gmail.com wrote:
 I am using wicket 1.5.2. I have implemented a custom IResourceFinder that
 locates my wicket template [HTML] files from say /assets folder. This
 custom resource finder is registered with the application during application
 init [getResourceSettings().setResourceFinder(new myCustomResFinder())]. Now
 I have a situation where the assets are going to get versioned at runtime,
 which means my lookup path should be something like /assets/1 or
 /assets/2. I am just looking for a way if someone had a similar situation
 earlier.

 There are a couple of ways I think this can be achieved.

 1. Listen to the assert version change event in wicket WebApplication and
 create a new instance of my custom resource finder with the new path, and
 set it again in ResourceSettings. I think this may be against any assumption
 that wicket makes that once WebApplication is initialized, the
 ResourceFinder is not going to change. Does wicket assumes that? Or can I go
 ahead and change the ResourceFinder anytime I want?

This is allowed. The only thing that bothers me is that there is no
synchronization when reading/writing the finder and you may experience
problems like seeing the old assets after assetVersionChanged event
has been fired for some request(s).


 2. My custom resource finder decorates around WebApplicationPath and adds
 the path to the decorated WebApplicationPath instance - I have to decorate
 this as I determine the path within this resource finder component. Now I
 can listen to the asset version change event in my resource finder but I
 won't be able to overwrite the existing path in the WebApplicationPath.
 WebApplicationPath maintains a private final list of paths. If I need to do
 this way, I will end up duplicating the WebApplicationPath code in my custom
 resource finder, which I am not really comfortable in doing.

I think you may use org.apache.wicket.util.file.Path instead of
WebApplicationPath.

And I think WebApplicationPath should extend Path because now they
share common logic...


 Has any one tried this? Any suggestion?

 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Wicket-ResourceFinder-implementation-for-resources-modified-at-runtime-tp4354878p4354878.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




-- 
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



Re: StalePageException with CryptoMapper

2012-02-04 Thread Martin Grigorov
Hi,

Any reason why you don't extend AjaxEventBehavior (with 'onclick' event) ?
It will do the same as the one below...

About StalePageException - can you create a mini quickstart that
reproduces this problem ?


On Fri, Feb 3, 2012 at 7:11 PM, Josh Chappelle jchappe...@4redi.com wrote:
 I'm getting a org.apache.wicket.request.mapper.StalePageException when
 using the CryptoMapper and clicking on a menu item. My menu items are a
 wrapper for the yui library that I created. The way that I'm creating the
 ajax callback is via a behavior. Below is my behavior. It works when I
 don't use the CryptoMapper.

 Any help is appreciated. Thanks.

 public class YuiMenuBarItemSelectionBehavior extends
 AbstractDefaultAjaxBehavior
 {
 private YuiMenuBarItem menuItem;
  public YuiMenuBarItemSelectionBehavior(YuiMenuBarItem menuItem)
 {
 this.menuItem = menuItem;
 }
  @Override
 protected void onBind()
 {
 super.onBind();
 menuItem.setUrl(javascript:  + generateCallbackScript(wicketAjaxGet(' +
 getCallbackUrl() + ').toString());
 }

 @Override
 protected void respond(AjaxRequestTarget target)
 {
 menuItem.onMenuItemClicked(target);
 }
 }



-- 
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



Re: DateTextField maxlength idea

2012-02-04 Thread Martin Grigorov
Ticket please :-)

On Fri, Feb 3, 2012 at 9:58 PM, Jim Pinkham pinkh...@gmail.com wrote:
 I have a simple data entry form with a date/time field.

 My end users (web newbies) have found another interesting way to confound
 the most clear and straightforward instruction I can devise regarding it's
 (obvious?) use.

 I watched an end user type an entire time into the hour component without
 tabbing over to the minute.

 So, I'd like to suggest a minor change to
 extensions.yui.calendar.DateTimeField.html to add the maxlength=2 to the
 current size=2 on the hour/min input controls.

 I think it might be a simple way to give earlier feedback  (I've found it
 unwise to rely on instructions like Please enter dates and times like
 this... ).

 I know I could accomplish this for my own instances, perhaps with a copy of
 this modified html in a spot higher in the classpath, or maybe an attribute
 modifier someplace..., but then I thought what is the downside of making it
 the default?   Sure, it would impact a lot of code, but unless some locale
 I don't know of has 3 digit minutes, I don't think in a negative way --- I
 was suprised to find no other similar past discussion; perhaps there is
 some obvious reason this isn't a good idea?   I can't be the first one to
 think of this, can I?

 Cheers,
 Jim

 In case all that's not clear, here's what I mean in code:

 MyPage.html
 span wicket:id=eventOnMM/DD/ [picker] HH MM [amPM]/span

 MyPage.java
 add(new DateTimeField(eventOn));

 DateTimeField.html in wicket-datetime-1.5-RC5.1.jar
 wicket:panel xmlns:wicket=http://wicket.apache.org;
  span style=white-space: nowrap;
  input type=text wicket:id=date size=12 /
  input type=text wicket:id=hours size=2 *maxlength=2* /
  span wicket:id=hoursSeparator#160;:/span
  input type=text wicket:id=minutes size=2 *maxlength=2* /
  select wicket:id=amOrPmChoice/select
  /span
 /wicket:panel



-- 
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



Re: Communication (in-vm) between webapps

2012-02-04 Thread Bas Gooren

Yeah, I was thinking the same thing.

The only thing I need to take care of then is access control, normal 
users should not be able to invoke a cache clear by calling the url. But 
since the call made from the admin to the frontend will not go over a 
public network I can simply use a pre-shared key for that.


Thanks to all who replied for their input!

Op 4-2-2012 11:02, schreef Martin Grigorov:

On Fri, Feb 3, 2012 at 10:17 PM, Serban.Balamacithespamtr...@gmail.com  wrote:

Some REST interface to be called through Httpclient from the admin
application I'd say it's the simplest approach.

I also think this is better than JMX, JMS/RabbitMQ/0mq, ... because
these require different ports to be open and sometimes this is
problematic.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Communication-in-vm-between-webapps-tp4355616p4355667.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: Communication (in-vm) between webapps

2012-02-04 Thread Francois Meillet
Hi Sebastian,


1) crossContext : 
Tomcat 7 - javadocs: 

Set to true if you want calls within this application to 
ServletContext.getContext() 
to successfully return a request dispatcher for other web applications running 
on 
this virtual host. 

But if you want something secure : 
Set to false (the default) in security conscious environments, to make 
getContext() always return null.
Easy, not scalable, unsecure


2) socket : 
Write a server and a listener using Socket and ServerSocket.
Inexpensive, not-scalable,  must manage new threads


3) jmx / mxbean
If you want to write a lot of lines of code  


4) Memory-mapped file with NIO
Easy, not scalable


5) messaging
It may be overkill at first glance. Only at first glance, 

If you want something scalable and secure, go for a messaging bus:
For example, why not using  JBoss HornetQ messaging system ?
It's scalable, multi-protocol, embeddable.

Your components will be loosely-coupled, scalable and secure, and your unit 
tests  much easier.
Especially if you deploy your web app to a cluster


François Meillet




Le 4 févr. 2012 à 12:17, Bas Gooren a écrit :

 Yeah, I was thinking the same thing.
 
 The only thing I need to take care of then is access control, normal users 
 should not be able to invoke a cache clear by calling the url. But since the 
 call made from the admin to the frontend will not go over a public network I 
 can simply use a pre-shared key for that.
 
 Thanks to all who replied for their input!
 
 Op 4-2-2012 11:02, schreef Martin Grigorov:
 On Fri, Feb 3, 2012 at 10:17 PM, Serban.Balamacithespamtr...@gmail.com  
 wrote:
 Some REST interface to be called through Httpclient from the admin
 application I'd say it's the simplest approach.
 I also think this is better than JMX, JMS/RabbitMQ/0mq, ... because
 these require different ports to be open and sometimes this is
 problematic.
 
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Communication-in-vm-between-webapps-tp4355616p4355667.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: Communication (in-vm) between webapps

2012-02-04 Thread Bas Gooren

François,

Thanks for your response.

Playing around with messaging has been on my wishlist for a while now.
I really like the features of JBoss HornetQ, in the context of my 
question especially the no dependencies, can be embedded through guice, 
handles persistence itself without external db and ... in-vm transport.


I didn't know about this project, so thanks for pointing it out.

Sebastian

Op 4-2-2012 12:39, schreef Francois Meillet:

Hi Sebastian,


1) crossContext :
Tomcat 7 - javadocs:

Set to true if you want calls within this application to 
ServletContext.getContext()
to successfully return a request dispatcher for other web applications running 
on
this virtual host.

But if you want something secure :
Set to false (the default) in security conscious environments, to make 
getContext() always return null.
Easy, not scalable, unsecure


2) socket :
Write a server and a listener using Socket and ServerSocket.
Inexpensive, not-scalable,  must manage new threads


3) jmx / mxbean
If you want to write a lot of lines of code 


4) Memory-mapped file with NIO
Easy, not scalable


5) messaging
It may be overkill at first glance. Only at first glance,

If you want something scalable and secure, go for a messaging bus:
For example, why not using  JBoss HornetQ messaging system ?
It's scalable, multi-protocol, embeddable.

Your components will be loosely-coupled, scalable and secure, and your unit 
tests  much easier.
Especially if you deploy your web app to a cluster


François Meillet




Le 4 févr. 2012 à 12:17, Bas Gooren a écrit :


Yeah, I was thinking the same thing.

The only thing I need to take care of then is access control, normal users 
should not be able to invoke a cache clear by calling the url. But since the 
call made from the admin to the frontend will not go over a public network I 
can simply use a pre-shared key for that.

Thanks to all who replied for their input!

Op 4-2-2012 11:02, schreef Martin Grigorov:

On Fri, Feb 3, 2012 at 10:17 PM, Serban.Balamacithespamtr...@gmail.com   
wrote:

Some REST interface to be called through Httpclient from the admin
application I'd say it's the simplest approach.

I also think this is better than JMX, JMS/RabbitMQ/0mq, ... because
these require different ports to be open and sometimes this is
problematic.


--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Communication-in-vm-between-webapps-tp4355616p4355667.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: Set Wicket User Session to Servlet's HttpSession

2012-02-04 Thread Kayode Odeyemi
Hi, thanks.

On Fri, Feb 3, 2012 at 8:05 PM, Serban.Balamaci thespamtr...@gmail.comwrote:

 Hello,
 It's not really clear what you mean and maybe you need to tell us what you
 want to do.


I want to use servlet session object for user authentication and not
wickets'.


 A Wicket session stores it's attributes into an implementation of the
 ISessionStore interface, but the default the store is HttpSessionStore, so
 the HttpSession. On the other hand, the wicket session can exist in a
 temporary state for the duration of the request and not have a HttpSession
 created. See bind(...) method in HttpSessionStore and you can see the
 Wicket
 session object being stored in a  httpsession attribute when the Wicket
 session needs to be persistent.
 setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, newSession);


But from what you've just explained, does that mean a wicket session is
HttpSession? Hence, I can just concentrate on implementing wicket session
and then retrieve it whenever its required even within a servlet - alas,
the HelloWorldServlet example which makes use of WicketSessionFilter?



 --
 View this message in context:
 http://apache-wicket.1842946.n4.nabble.com/Set-Wicket-User-Session-to-Servlet-s-HttpSession-tp4355593p4355644.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




-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde


Re: Communication (in-vm) between webapps

2012-02-04 Thread Jeremy Thomerson
I agree a messaging queue is a nice scalable system.  But I also think
pragmatic approaches are best.  You don't have messages that need to be
sent right now (data sent between disparate apps).  You have a single
command that needs to be invoked.  That happens to be what HTTP is *really*
good at.  And, you're already writing a web app.  That said, I'd choose
Serban's recommendation.  Create a Wicket bookmarkable page that takes a
pre-shared key or some other method of authentication and call that from
the app.  If it's just an encrypted URL param that gives authorization you
don't even need to call it from the other app - just give the user a link
to click that goes straight to the flush cache page on the frontend.
 Open that in a new window, have your page print out all your strings are
belong to us and you're done :)


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

On Sat, Feb 4, 2012 at 6:47 AM, Bas Gooren b...@iswd.nl wrote:

 François,

 Thanks for your response.

 Playing around with messaging has been on my wishlist for a while now.
 I really like the features of JBoss HornetQ, in the context of my question
 especially the no dependencies, can be embedded through guice, handles
 persistence itself without external db and ... in-vm transport.

 I didn't know about this project, so thanks for pointing it out.

 Sebastian

 Op 4-2-2012 12:39, schreef Francois Meillet:

  Hi Sebastian,


 1) crossContext :
 Tomcat 7 - javadocs:

 Set to true if you want calls within this application to
 ServletContext.getContext()
 to successfully return a request dispatcher for other web applications
 running on
 this virtual host.

 But if you want something secure :
 Set to false (the default) in security conscious environments, to make
 getContext() always return null.
 Easy, not scalable, unsecure


 2) socket :
 Write a server and a listener using Socket and ServerSocket.
 Inexpensive, not-scalable,  must manage new threads


 3) jmx / mxbean
 If you want to write a lot of lines of code 


 4) Memory-mapped file with NIO
 Easy, not scalable


 5) messaging
 It may be overkill at first glance. Only at first glance,

 If you want something scalable and secure, go for a messaging bus:
 For example, why not using  JBoss HornetQ messaging system ?
 It's scalable, multi-protocol, embeddable.

 Your components will be loosely-coupled, scalable and secure, and your
 unit tests  much easier.
 Especially if you deploy your web app to a cluster


 François Meillet




 Le 4 févr. 2012 à 12:17, Bas Gooren a écrit :

  Yeah, I was thinking the same thing.

 The only thing I need to take care of then is access control, normal
 users should not be able to invoke a cache clear by calling the url. But
 since the call made from the admin to the frontend will not go over a
 public network I can simply use a pre-shared key for that.

 Thanks to all who replied for their input!

 Op 4-2-2012 11:02, schreef Martin Grigorov:

 On Fri, Feb 3, 2012 at 10:17 PM, Serban.Balamacithespamtrapp@**
 gmail.com thespamtr...@gmail.com   wrote:

 Some REST interface to be called through Httpclient from the admin
 application I'd say it's the simplest approach.

 I also think this is better than JMX, JMS/RabbitMQ/0mq, ... because
 these require different ports to be open and sometimes this is
 problematic.

  --
 View this message in context: http://apache-wicket.1842946.**
 n4.nabble.com/Communication-**in-vm-between-webapps-**
 tp4355616p4355667.htmlhttp://apache-wicket.1842946.n4.nabble.com/Communication-in-vm-between-webapps-tp4355616p4355667.html
 Sent from the Users forum mailing list archive at Nabble.com.

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



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




Re: calling shell script from Wicket java program

2012-02-04 Thread Jeremy Thomerson
On Sat, Feb 4, 2012 at 4:56 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 On Fri, Feb 3, 2012 at 5:53 AM, abhisheks sachini...@gmail.com wrote:
  i am developing a web application using apache wickets. I need to call a
  shell script residing on my local disk from java code.
 
  this is the section of code under concern :
 
  ProcessBuilder builder = new
 
 ProcessBuilder(sh,/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh);
  builder.redirectErrorStream(true);
 final Process process =
 builder.start();
 }
  process.waitFor();
 
  --
 
  This is piece of code successfully runs fine and execute a shell when
 this
  code is a part of java prgram residing anywhere on my laal disk. However,
  when i make a jar file of a progeam , put in webapps folder , and start
 the
  web application , it reports permission denied error on test.sh script.
 
  I then modify the line as :
 
  ProcessBuilder builder = new ProcessBuilder(sudo, -A,
 
 sh,/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh);
  and set the SUDO_ASKPASS env variable to script returning my sudo
 password ,
  then it reports the following error :
  sudo: 3 incorrect password attempts and script calling is failed. Again
 this
  works correctly when i run the program outside the web development
  environment , it is able to read my sudo password correctly at run time
 with
  -A option. Why is it failing when running the same program from web
  application ?  please help !!

 Maybe your web server runs with a user which has no permissions to
 become different user (via sudo).
 When you run it as a normal Java program you run it with your user
 which has this permission.

 In any case it has nothing to do with Wicket.


And if your webapp *is* running as a user with sudo access you're just
asking for trouble.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*


Re: Property Model Issue

2012-02-04 Thread James Carman
I would avoid cpms like the plague.  Too much magic.
On Feb 3, 2012 5:12 PM, Sam Barrow s...@sambarrow.com wrote:


 On Fri, 2012-02-03 at 13:57 -0800, Dan Retzlaff wrote:
  Hi Sam,
 
  I think your use of Item#setModel() and Component#initModel() are
  unconventional. Try:
 

 Hi Dan,

 Yes I never really liked my item.setModel() technique, just didn't seem
 right to me but I've seen it in more than one tutorial so I figured it
 was the way it was done. I actually moved the compounding part over the
 newItem method in dataview just now though, seems cleaner.

  populateItem(ItemPost item) {
  item.add(new ProductPanel(product, item.getModel());
  }
 
  ProductPanel(String id, IModelProduct model) {
  super(id, CompoundPropertyModel.of(model));
  add(new Label(name));
  add(new Label(condition));
  }
 

 I'm sure this would work, just wondering if there's a better way to do
 this? Is it good practice to manipulate the model in the constructor
 like that? Doesn't seem right to me as the model may need to change
 (maybe via ajax?). I try to never mess with my models like that outside
 of the rendering phase. I've been toying with wicket occasionally for
 over a year now, but never gone this far with it so I'm still learning
 how it all works.

 I would if at all possible like to retain the ability to create a new
 ProductPanel without specifying the model in the constructor. This seems
 to be the way things are usually done in Wicket so I figured there must
 be a better way.

 Product is a property of post so I'd be specifying it in two different
 places, and again if I wanted to add any more composited components
 under ProductPanel.

 I've corrected your code to reflect this (I just got your next message).

  populateItem(ItemPost item) {
  item.add(new ProductPanel(product, new
 PropertyModelProduct(item.getModel(), product));
  }
 

 I was using the compoundpropertymodel to avoid specifying the product
 property manually as is done above, but that part is working for me with
 no issues, it's just inside ProductPanel that I'm having problems.

 It's not that I'm really that lazy, just an issue of best practice for
 me.

  On Fri, Feb 3, 2012 at 12:51 PM, Sam Barrow s...@sambarrow.com wrote:
 
   Hi guys,
  
   I'm having an issue with property models.
  
   I have a DataView running over a number of Post objects. The Post
 object
   has a property named product with appropriate getter/setter.
  
   new DataViewPost(posts, provider) {
protected void populateItem(final ItemPost item) {
  item.setModel(CompoundPropertyModel.of(item.getModel()));
  item.add(new ProductPanel(product));
}
   }
  
   The issue is within ProductPanel. It has a number of labels, each only
   specifying a name (no model). In my initModel() I am creating a
   CompoundPropertyModel around super.initModel(). I was expecting it to
   pull these properties from the model object of my ProductPanel.
  
   public class ProductPanel extends GenericPanelProduct {
public ProductPanel(final String id) {
  add(new Label(name));
  add(new Label(condition));
}
protected IModel? initModel() {
  return CompoundPropertyModel.of(super.initModel());
}
   }
  
   But I get this error: org.apache.wicket.WicketRuntimeException: No get
   method defined for class: class com.cellcycleusa.domain.Post
 expression:
   name.
  
   Seems that it's trying to access the Post object from the DataView to
   pull the property from, not the model object of the ProductPanel
 itself.
  
   Now the really funny part is that if I just add this to ProductPanel,
   everything works fine:
  
   protected void onBeforeRender() {
getModel();
super.onBeforeRender();
   }
  
   Or if I specify the model objects for the labels within ProductPanel
   like this:
  
   new Label(name, new ComponentPropertyModelString(name))
  
   That works as well.
  
   What am I doing wrong?
  
   --
  
   Sam Barrow
   Squidix IT Services
  
  
  
  
   -
   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: Property Model Issue

2012-02-04 Thread Sam Barrow

On Sat, 2012-02-04 at 10:27 -0500, James Carman wrote:
 I would avoid cpms like the plague.  Too much magic.
 On Feb 3, 2012 5:12 PM, Sam Barrow s...@sambarrow.com wrote:
 

Yeah, I know what you mean. I usually try to avoid them, I'm not too
fond of runtime reflection, loss of compile time type checking, etc. At
the same time though there is something to be said for doing things the
conventional way within a framework, and from everything I've seen this
is it.

I actually figured out the problem. When wicket tries to initModel it
searches parent components for their model, but it doesn't use getModel,
it uses getModelImpl, which does none of initModel magic. In effect,
it's incapable of handling chains of nested models in which more than
two links in a row are not manually specified.



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



Re: DateTextField maxlength idea

2012-02-04 Thread Jim Pinkham
WICKET-4386 https://issues.apache.org/jira/browse/WICKET-4386
On Sat, Feb 4, 2012 at 5:27 AM, Martin Grigorov mgrigo...@apache.orgwrote:

 Ticket please :-)

 On Fri, Feb 3, 2012 at 9:58 PM, Jim Pinkham pinkh...@gmail.com wrote:
  I have a simple data entry form with a date/time field.
 
  My end users (web newbies) have found another interesting way to confound
  the most clear and straightforward instruction I can devise regarding
 it's
  (obvious?) use.
 
  I watched an end user type an entire time into the hour component without
  tabbing over to the minute.
 
  So, I'd like to suggest a minor change to
  extensions.yui.calendar.DateTimeField.html to add the maxlength=2 to
 the
  current size=2 on the hour/min input controls.
 
  I think it might be a simple way to give earlier feedback  (I've found it
  unwise to rely on instructions like Please enter dates and times like
  this... ).
 
  I know I could accomplish this for my own instances, perhaps with a copy
 of
  this modified html in a spot higher in the classpath, or maybe an
 attribute
  modifier someplace..., but then I thought what is the downside of making
 it
  the default?   Sure, it would impact a lot of code, but unless some
 locale
  I don't know of has 3 digit minutes, I don't think in a negative way ---
 I
  was suprised to find no other similar past discussion; perhaps there is
  some obvious reason this isn't a good idea?   I can't be the first one to
  think of this, can I?
 
  Cheers,
  Jim
 
  In case all that's not clear, here's what I mean in code:
 
  MyPage.html
  span wicket:id=eventOnMM/DD/ [picker] HH MM [amPM]/span
 
  MyPage.java
  add(new DateTimeField(eventOn));
 
  DateTimeField.html in wicket-datetime-1.5-RC5.1.jar
  wicket:panel xmlns:wicket=http://wicket.apache.org;
   span style=white-space: nowrap;
   input type=text wicket:id=date size=12 /
   input type=text wicket:id=hours size=2 *maxlength=2* /
   span wicket:id=hoursSeparator#160;:/span
   input type=text wicket:id=minutes size=2 *maxlength=2* /
select wicket:id=amOrPmChoice/select
   /span
  /wicket:panel



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

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




Re: Property Model Issue

2012-02-04 Thread James Carman
I wouldn't necessarily say that CPMs are the wicket way.

On Sat, Feb 4, 2012 at 11:32 AM, Sam Barrow s...@sambarrow.com wrote:

 On Sat, 2012-02-04 at 10:27 -0500, James Carman wrote:
 I would avoid cpms like the plague.  Too much magic.
 On Feb 3, 2012 5:12 PM, Sam Barrow s...@sambarrow.com wrote:


 Yeah, I know what you mean. I usually try to avoid them, I'm not too
 fond of runtime reflection, loss of compile time type checking, etc. At
 the same time though there is something to be said for doing things the
 conventional way within a framework, and from everything I've seen this
 is it.

 I actually figured out the problem. When wicket tries to initModel it
 searches parent components for their model, but it doesn't use getModel,
 it uses getModelImpl, which does none of initModel magic. In effect,
 it's incapable of handling chains of nested models in which more than
 two links in a row are not manually specified.



 -
 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



Setting/changing id for components after creation.

2012-02-04 Thread msalman
I have a panel which adds another child panel created by other users.  The
problem for me is that the parent panel expects the child panel to have a
particular id (formPanel).  The child panel will itself be a derived class
and will have a corresponding wicket:extend html file.  Since there is no
setId(String id) method provided, what will be the best way to handle this
problem?

I had thought of creating derived child panel classes with the required id
set by the derived class itself.  The user will create another derived class
off former class ... but this just ends up with way too many classes
depending on future parent panels, etc.

I hope I have not made it too complicated to understand.  

Thanks,

-msalman

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Setting-changing-id-for-components-after-creation-tp4358004p4358004.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-Source: Click-through from browser back to Java source

2012-02-04 Thread Jenny Brown
Wicket-source 1.5.0.7 is available now as a full release in maven central.

This fixes a bug where ajax components were skipped; should work solidly
now in all cases.  If you have a bug report, there's an issue tracker on
the github project site.  https://github.com/42Lines/wicket-source

I also backported for wicket 1.4.x compatibility and that is available as a
full release in maven central now.

Version numbering is (wicket_version).(my_version).


Jenny Brown