[Lift] Customizing generated form elements without touching scala code
Hi, I'm trying to get my first form in Lift running and I'm having the following problem: I use for example SHtml.text(..) to create a text input element. Unfortunately, this element has no specific class or id such that I can customize it using CSS or whatever. I know that I can add some parameters to SHtml.text(..) which are passed to the generated form element but this means that I have style information in my scala code. And this is, in my opinion, very ugly. Is there a better solution? I could imagine something like e:myfield class=somecssclass/. This class information is accessible in scala so the form generator could automatically add it to the generated element... Thanks in advance for your help!! Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Re: Customizing generated form elements without touching scala code
Thank you for your answer, also thanks to Jeppe who posted the same solution. I disagree with the unglyness you are talking about just because Snipets are UI elements. I already read that and although I don't want to start a discussion on this, I want to share my opinion with you: I already read in some blog entries and also here on the mailing list that lift completely avoids the problem of having business logic in your views/templates. I think in general, this is a very good idea. On the other hand, many people say snippets are part of the view. In almost all examples I found, you can see business logic in the snippets. Is this really better now? I think you are still mixing business logic and UI stuff, just on a different level. Of course, you can seperate that but this adds unnecessary complexity to an application. Or am I missing something? I'm still a beginner in the scala/lift world... :-) Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
[Lift] Implementing You are here:
Hi, I want to implement something like You are here: Root - Somewhere 1 - Somewhere 1.1 which is displayed on all pages. Is it possible to use SiteMap to do that? Can someone give me a hint how to do that? Thanks, Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Implementing You are here:
I want to implement something like You are here: Root - Somewhere 1 - Somewhere 1.1 which is displayed on all pages. Is it possible to use SiteMap to do that? Can someone give me a hint how to do that? Have a look at the Menu snippet. I think the li_path prefix can be used to make a breadcrumb... The problem is that it still renders all roots. Assume I have a menu like Node 1 - Node 1.1 - Node 1.1.1 Node 2 - Node 2.1 and assume I'm visiting Node 1.1.1. Then, I just want to have You are here: Node 1 - Node 1.1 - Node 1.1.1 Menu.builder will always construct Node 1 - Node 1.1 - Node 1.1.1 Node 2 i.e., still prints Node 2. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Mapper question / autogenerate some number
Does really nobody know something about my problem? Something like this is not possible at the moment is also ok... :-) Am 03.01.10 22:46, schrieb Julian Backes: Hi, I have the following problem: For simplicity, assume I want to store users in the database. Before storing a user the first time in the database (using someNewUser.save), I want to create a special unique number for this user (which we need in our company) and store this number together with the new user. This number is based on several values and some of them need to be read from the database. My first idea was to add something to beforeCreate in the meta object but I'm not sure how to do the computation of the number together with the save operation in one transaction (which is absolutely necessary)? And are there better places to do this? I read something about putting the whole request in one transaction but this is not what I want. I'm currently only using the Mapper stuff (because I want a pure scala ORM) and not the whole Lift framework. Thanks in advance, Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Mapper question / autogenerate some number
Thanks for your answer!! You can use mapper by itself. There's a dependency on lift webkit I believe. There might be some other issues, as i don't if anyone is using it that way. This is perfectly working As for the number, are you talking about a userId? Why would you think you can't set an arbitrary field in Mapper? no, it is not a userId, just think of it as some string. Let's call it userSpecialString for the moment. I know that I can set some field but my problem is that when *storing a new user in the database*, the system should: 1) start transaction 2) generate special number/string from database 3) set userSpecialString to this generated thing 4) store new user in the database 5) end transaction Steps 2-4 are no problem. My problem is how to do this in one transaction (steps 1 and 5) and where the best place is so that steps 1-5 automatically happen when calling newUser.save() Julian On Wed, Jan 6, 2010 at 11:11 AM, Julian Backes julianbac...@googlemail.com mailto:julianbac...@googlemail.com wrote: Does really nobody know something about my problem? Something like this is not possible at the moment is also ok... :-) Am 03.01.10 22:46, schrieb Julian Backes: Hi, I have the following problem: For simplicity, assume I want to store users in the database. Before storing a user the first time in the database (using someNewUser.save), I want to create a special unique number for this user (which we need in our company) and store this number together with the new user. This number is based on several values and some of them need to be read from the database. My first idea was to add something to beforeCreate in the meta object but I'm not sure how to do the computation of the number together with the save operation in one transaction (which is absolutely necessary)? And are there better places to do this? I read something about putting the whole request in one transaction but this is not what I want. I'm currently only using the Mapper stuff (because I want a pure scala ORM) and not the whole Lift framework. Thanks in advance, Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com mailto:liftweb@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com mailto:liftweb%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com mailto:liftweb@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com mailto:liftweb%2bunsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- James A Barrows -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Mapper question / autogenerate some number
In this previous question: http://old.nabble.com/%28Newbie-Question%29-How-to-do-simple-transaction-with-mapper--td26191398.html I find the following: import net.liftweb.*mapper*.{DB, DefaultConnectionIdentifier} DB.use(DefaultConnectionIdentifier) { conn = conn.setAutoCommit(false) ... // CRUDs if(success) conn.commit else conn.rollback conn.setAutoCommit(true) } Have you tried something like this? I read that post but I still have the problem that I don't know where to integrate this. Override the save() function of the user mapper class? Or override the save() function of the meta user mapper class? Or add something to the beforeCreate() handlers? This last case (beforeCreate()) does not work in my opinion because I cannot start a transaction there that wraps the whole create process... -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Mapper question / autogenerate some number
if you do the query in beforeCreate, it will be part of the current transaction... the transactional scope is created by the time beforeCreate is called. Does that mean that the whole create process is already in one transaction? That would be great :-) -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
[Lift] Mapper question / autogenerate some number
Hi, I have the following problem: For simplicity, assume I want to store users in the database. Before storing a user the first time in the database (using someNewUser.save), I want to create a special unique number for this user (which we need in our company) and store this number together with the new user. This number is based on several values and some of them need to be read from the database. My first idea was to add something to beforeCreate in the meta object but I'm not sure how to do the computation of the number together with the save operation in one transaction (which is absolutely necessary)? And are there better places to do this? I read something about putting the whole request in one transaction but this is not what I want. I'm currently only using the Mapper stuff (because I want a pure scala ORM) and not the whole Lift framework. Thanks in advance, Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Foreign Key constraints are not created by schemify
OK, I've run into a snag. Schemifier does support foreign key creation, as do most of the database vendors. The ManyToMany Mapper support, however, seems to expect no foreign key constraints, since it's explicitly testing broken refs in the ManyToManySpecs tests: I do not really know something about the ManyToMany stuff in mapper but in my opinion, it should support foreign keys. You always have situations where you change something in the database by hand. In such cases, it's always good to have foreign keys... I wonder if we should have FK generation be a configuration parameter for schemify. I could change the code so that the default schemify method continues to generate DDL without FK constraints, but add a second schemify method that takes a boolean parameter controlling whether FKs are generated. Sounds good to me That, coupled with the DriverType.supportsForeignKeys_?, would allow people to add FKs if they want. Thoughts? I had the problem that when I wanted to test the foreign key support, I had to recompile most parts of lift with DriverType.supportsForeignKeys_? set to true (which was no fun because I had to download many many dependencies from the incredible slow maven repo). Wouldn't it make sense to allow setting DriverType.supportsForeignKeys_? at runtime? This would be useful when, for example, some database system does not support foreign keys when the corresponding Lift version is released but starts supporting it two weeks later. In such a situation, I do not want do recompile Lift just to have DriverType.supportsForeignKeys_? set to true... Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Foreign Key constraints are not created by schemify
I agree on both points (foreign keys and documentation). Please open a ticket asking for proper foreign key support and I'll work on it next week. http://github.com/dpp/liftweb/issues/#issue/224 Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Foreign Key constraints are not created by schemify
Hi Derek, It's been a long time since I looked at that particular code, so I may have misspoke. Having said that, if it's currently disabled in the driver I'm not sure why and I would want to review it before saying that it works properly in all cases. I think the problem here is that the user expects (like I did) foreign keys to be created if he uses mapper classes referencing other mapper classes. This behaviour should at least be mentioned somewhere in the documentation (btw, the documentation is in my opinion the biggest problems of Lift at the moment). I think, using a relational database without foreign keys is somehow not very useful because you never really know whether you have referential integrity... It would be great if you looked at the code and enabled it. This would really be an improvement for the mapper stuff in Lift 1.1 Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Re: [Lift] Foreign Key constraints are not created by schemify
Hi Lift Community, this is a reply to my own question: I'm trying to get my first scala/lift app working and I have a problem: Schemifier.schemify(...) creates everything, i.e. tables, primary keys, indices but it does not create the foreign key constraints. After hours of compiling and testing, I stumbled across some messages here on the mailing lists which discussed the same problem (I have no idea why I haven't seen them before). In one message, Derek said At this time we don't support it, but feel free to file an issue. I'll have time at some point to work on it, and I think that it would be useful to generate. What does he mean by we don't support it? I've seen the code for generating foreign key constraints in Schemifier.scala I just needed to set supportsForeignKeys_? in the postgresql driver class to true and... it works now. The generated foreign key constraints are perfectly ok. Is there a reason that this code is not used? Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
[Lift] Foreign Key constraints are not created by schemify
Hi, I'm trying to get my first scala/lift app working and I have a problem: Schemifier.schemify(...) creates everything, i.e. tables, primary keys, indices but it does not create the foreign key constraints. I've seen in Schemifier.scala SQL code for generating foreign key constraints so I think it should work. Or am I wrong? I tried Lift 1.0 and 1.1-M7 I also tested the pocketchangeapp from http://github.com/tjweir/pocketchangeapp but still the same problem. I'm using PostgreSQL (postgresql-8.4-701.jdbc4.jar) and Scala 2.7.7. Server is PostgreSQL 8.3.7. Here the SQL log when doing a mvn jetty:run in pocketchangeapp: INFO - CREATE TABLE users (firstname VARCHAR(32) , lastname VARCHAR(32) , email VARCHAR(48) , locale VARCHAR(16) , timezone VARCHAR(32) , password_pw VARCHAR(48) , password_slt VARCHAR(20) , id BIGSERIAL , superuser BOOLEAN , validated BOOLEAN , uniqueid VARCHAR(32)) INFO - ALTER TABLE users ADD CONSTRAINT users_PK PRIMARY KEY(id) INFO - CREATE TABLE tag (name VARCHAR(64) , id BIGSERIAL , account BIGINT) INFO - ALTER TABLE tag ADD CONSTRAINT tag_PK PRIMARY KEY(id) INFO - CREATE TABLE account (name VARCHAR(100) , id BIGSERIAL , description VARCHAR(300) , owner BIGINT , externalaccount VARCHAR(300) , balance DECIMAL(16,2) , is_public BOOLEAN) INFO - ALTER TABLE account ADD CONSTRAINT account_PK PRIMARY KEY(id) INFO - CREATE TABLE accountadmin (id BIGSERIAL , administrator BIGINT , account BIGINT) INFO - ALTER TABLE accountadmin ADD CONSTRAINT accountadmin_PK PRIMARY KEY(id) INFO - CREATE TABLE accountviewer (id BIGSERIAL , viewer BIGINT , account BIGINT) INFO - ALTER TABLE accountviewer ADD CONSTRAINT accountviewer_PK PRIMARY KEY(id) INFO - CREATE TABLE accountnote (note TEXT , id BIGSERIAL , account BIGINT) INFO - ALTER TABLE accountnote ADD CONSTRAINT accountnote_PK PRIMARY KEY(id) INFO - CREATE TABLE expense (dateof TIMESTAMP , amount DECIMAL(16,2) , description VARCHAR(100) , notes VARCHAR(1000) , id BIGSERIAL , serialnumber BIGINT , account BIGINT , currentbalance DECIMAL(16,2) , receiptmime VARCHAR(100) , receipt BYTEA) INFO - ALTER TABLE expense ADD CONSTRAINT expense_PK PRIMARY KEY(id) INFO - CREATE TABLE expensetag (id BIGSERIAL , tag BIGINT , expense BIGINT) INFO - ALTER TABLE expensetag ADD CONSTRAINT expensetag_PK PRIMARY KEY(id) INFO - CREATE INDEX users_email ON users ( email ) INFO - CREATE INDEX users_uniqueid ON users ( uniqueid ) INFO - CREATE INDEX tag_account ON tag ( account ) INFO - CREATE INDEX account_owner ON account ( owner ) INFO - CREATE INDEX accountadmin_administrator ON accountadmin ( administrator ) INFO - CREATE INDEX accountadmin_account ON accountadmin ( account ) INFO - CREATE INDEX accountviewer_viewer ON accountviewer ( viewer ) INFO - CREATE INDEX accountviewer_account ON accountviewer ( account ) INFO - CREATE INDEX accountnote_account ON accountnote ( account ) INFO - CREATE INDEX expense_account ON expense ( account ) INFO - CREATE INDEX expensetag_tag ON expensetag ( tag ) INFO - CREATE INDEX expensetag_expense ON expensetag ( expense ) INFO - Bootstrap up Thanks in advance, Julian -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
[Lift] Accessing functions of a lift webapp from the command line
Hi Lift Community, I'm pretty new to the Scala/Lift world. My idea is to port a web application written by me in PHP to Scala/Lift. Unfortunately, the PHP version also has some functions which are used by some cronjob, i.e. from the command line. So my first question is: Is there any possibility to access functions in a Lift webapp from the command line? My idea in a more general version is: I want to write some application which can be accessed in multiple ways: for example from the command line (as just described), from the web using normal xhtml pages, from the web using json requests etc. Of course, I want to write as less functionality as possible twice so there should be some core which has the logic (and probably some model/database in the background) and several interfaces (one command line interface, one webinterface, one json interface...) which should only act as translators. For example the web interface gets some (let's say POST) request, extracts the data needed to process the request and passes these date to the core. The core does something and returns the data needed for an answer. The webinterface takes these data and creates some xhtml page out of it. In contrast to that, the json interface only gets a request in json format, extracts the data, passes them to the core, gets the result and sends back a *json* answer. The command line interface will just take some command line arguments, extract data, pass them and answer with *some plain text*. So my second question is: How does this idea fit into the lift world? One reason for my questions: As I understood it, Lift is heavily bound to the webinterface part I described above. For example the snippets which seem to be one very important part of Lift can only work with xml/xhtml data. I hope you understand my ideas and questions, I'm still learning English ;-) Thanks in advance for all answers!! Julian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---