if (result != null && result.moveToFirst()); do { Post post = new Post(); post.setPostId(result.getInt(0)); posts.add(post); .... } while (result.moveToNext()); }
public void savePost(long authorId, String text) { Post p = new Post(); p.setText(text); // No SELECT query here. // Existence of Author is ensured by foreign key constraint on Post. p.setAuthor(s.load(Author.class, authorId)); s.save(p); }
/** * Executes a POST request. * * @param url url of resource. * @param content content to be posted. * @param connectTimeout connection timeout in milliseconds. * @param readTimeout read timeout in milliseconds. * @return {@link Post} object. */ public static Post post(String url, byte[] content, int connectTimeout, int readTimeout) { try { return new Post(url, content, connectTimeout, readTimeout); } catch (Exception e) { throw new HttpException("Failed URL: " + url, e); } }
/** * Executes a POST request. Often used to post form parameters: * * <pre> * Http.post("http://example.com/create").param("name1", "val1"); * </pre> * * @param url url of resource. * @param connectTimeout connection timeout in milliseconds. * @param readTimeout read timeout in milliseconds. * @return {@link Post} object. */ public static Post post(String url, int connectTimeout, int readTimeout) { try { return new Post(url, null, connectTimeout, readTimeout); } catch (Exception e) { throw new HttpException("Failed URL: " + url, e); } }
// after fetching a post called "post" var Post = Parse.Object.extend("Feed"); var newpost = new Post(); var keys = ["title", "author" /* ...the keys you want to copy unchanged */ ]; pfClone(post, newpost, keys); // change other properties of newpost here
Category category = ...; Post newPost = new Post(..); category.getPosts().add(newPost); entityManager.persist(newPost); category = entityManager.merge(category); // may not be needed if category is already managed
$(window).on("html_loaded", function(e) { $(".submit_button").click(function(e) { // This creates our new Post object var Post = Parse.Object.extend("Post"); var myPost = new Post(); ... }); });
self.addPost = function () { var post = new Post(); post.Message(self.newMessage()); return $.ajax({ url: postApiUrl, dataType: "json", contentType: "application/json", cache: false, type: 'POST', data: { post: ko.toJSON(post), id: $("#Locations").val() } });
posts = new PostCol({userId:id = cookieVal[0].split('=')[1],start:1}); post = new Post({collection:posts}); posts.on('reset', post.render.bind(post)); //This should really go in PostView initialize posts.fetch();
var p = new Post({ title: newTitle, content: newContent }); p.save(function(err){ if (err) throw err; });
// Create a new Parse object var Post = new ParseObject("Post"); var post = new Post(); // Save it to Parse post.save({"title": "Hello World"}).then(function(object) { alert("Yay! It worked!"); });
try ( Statement st = con.createStatement(); ResultSet rs = st.executeQuery("SELECT * FROM posts LIMIT 1"); ) { return rs.next() ? this.marshall(rs, new Post()) : null; } catch (SQLException x) { x.printStacktrace(); }
for( int i = 0; i < num; i++){ Post post = new Post(); post.setTitle( TITLE[i] ); list.add(post); }
var p2=new Post({id:id}); p2.on('change', function(post){ console.log(post.attributes); var view= new MbDetail(); view.render(p2); } p2.fetch();
private void writeNewPost(String userId, String username, String title, String body) { String key = mDatabase.child("posts").push().getKey(); Post post = new Post(userId, username, title, body); Map<String, Object> postValues = post.toMap(); Map<String, Object> childUpdates = new HashMap<>(); childUpdates.put("/posts/" + key, postValues); childUpdates.put("/user-posts/" + userId + "/" + key, postValues); mDatabase.updateChildren(childUpdates); }
private void writeNewPost(String userId, String username, String title, String body) { // Create new post at /user-posts/$userid/$postid and at // /posts/$postid simultaneously String key = mDatabase.child("posts").push().getKey(); Post post = new Post(userId, username, title, body); Map<String, Object> postValues = post.toMap(); Map<String, Object> childUpdates = new HashMap<>(); childUpdates.put("/posts/" + key, postValues); childUpdates.put("/user-posts/" + userId + "/" + key, postValues); mDatabase.updateChildren(childUpdates); }
String getPost = "SELECT * FROM " + TABLE_POST + ";"; Cursor result = getReadableDatabase().rawQuery(getPost, null); List posts = new ArrayList();{ Log.d("count", result.getCount() + " post rows"); if (result .moveToFirst()) { do { Post post = new Post(); post.setPostId(result.getInt(0)); posts.add(post); .... } while (result .moveToNext()); } result .close();
@RequestMapping("/posts") public String showAllPosts(ModelMap model) { List<Post> posts = postDao.findAll(); model.addAttribute("post", new Post()); // Add empty form backing object model.addAttribute("posts", posts); return "posts"; }
// Crete and populate our Post Post newPost = new Post(); newPost.setUsername("XXX"); newPost.setLink("xxx"); newPost.setDate("xxx"); // Display the post. postContainer.add(newPost);