could anybody give me a good idea or hint (not a tool) how I could implement a JDBC meta data based automatic generation of html forms?
I have solved this before in a Java standalone program - now I want to expand the idea within html.
I do NOT want to use Spring, Wicket or JSF to solve the problem, I want to do it myown to learn from scratch.
I have searched really a lot, I found a lot of stuff, but nothing which could answer my question. But I am sure this problem has been solved in the past a dozen times.
Thank you
Alex
Create a servlet class, let it call your "Java standalone program" in the doGet() method, get the desired data in form of some List<Row> from it, put it in the request scope and forward the request to JSP
List<Row> rows = yourProgram.list();
request.setAttribute("rows", rows);
request.getRequestDispatcher("/WEB-INF/list.jsp").forward(request, response);
And finally in /WEB-INF/list.jsp use the JSTL c:forEach to display it.
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%#taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
...
<table>
<tr>
<c:forEach items="${rows[0].columns}" var="column">
<th><c:out value="${column.name}" /></th>
</c:forEach>
</tr>
<c:forEach items="${rows}" var="row">
<tr>
<c:forEach items="${row.columns}" var="column">
<td><input type="text" name="${fn:escapeXml(column.name)}" value="${fn:escapeXml(column.value)}" /></td>
</c:ForEach>
</tr>
</c:forEach>
</table>
Let it submit to a servlet by <form method="post"> and gather the data in doPost() method.
Related
I have a data table that displays multiple records in one page.. I need to do the following:
1- Pagination of the data table pages.
2- Display 10 records per page and give the user the ability to increase this number. For example.. (10, 20, 50, 100) records per page.
How can I do it using VueJS?
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>Date & Time</th>
</thead>
<tbody>
<tr> <td>1</td>
<td>Sara</td> <td>example1#example.com</td>
<td>12/2/2021 16:40</td>
</tr>
<tr>
<td>2</td>
<td>Safa</td> <td>example2#example.com</td>
<td>24/2/2021 08:40</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-4">
Showing 10 out of 100
</div>
<div class="col-8 text-end">
<div class="btn-group" role="group" aria-label="Basic outlined example">
<button type="button" class="btn btn-outline-primary">1</button>
<button type="button" class="btn btn-outline-primary">2</button>
<button type="button" class="btn btn-outline-primary">3</button>
</div>
</div>
</div>
You could tackle this a number of ways. To start, you could keep all of your logic in your current file, open a script block, define a Vue instance, set up a data object, define a data variable for the number of items per page as well as anything else you want to track.
Then, you'll use a v-model binding on an input field in your template, which you would need to read the Vue docs to get a better handle on (very good documentation available). Keep it simple to start. Don't have pagination, just begin with an input field in which your user enters the number of items that should render in the table. Get that working. Then, shift to a drop-down with multiple defined options, which again you could define in the data object and iterate through those (new now) in your template using a v-for loop. You can use a prebuilt dropdown with any number of Vue UI libraries like Vuetify or VueBoostrap or many others. You'll need to read their respective documentation, but it's pretty straight forward.
Then to add pagination, you'd need to learn about routing and route parameters and how to send such parameters to your API as params on the get request. Axios can handle this for you.
Sounds like you need to start with basics and get comfortable with simple projects. Building fully functional data tables are quite hard! There are many great libraries available for VueJS that help you with data tables, even large commercial ones as well.
Read the documentation and watch YT tutorials before tackling complex stuff. To be sure, tables are well suited for components as opposed to single templates. You would need to learn how to separate out logic, e.g. a dropdown component. Take your time and keep learning!
Here would be a list of table related projects to help you understand, see their docs and examples:
https://awesome-vue.js.org/components-and-libraries/ui-components.html#table
-Marcus
Im beginner in opencart developing, and now i need something pretty simple ( as i think...) im using opencart 2.1.0.1 and i made a simple table
<table align="left" border="1" cellspacing="1" style="table-layout:fixed;width:500px;">
<tbody>
<tr>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
</tr>
<tr>
<td>here i want the product price</td>
<td>here i want the prduct price</td>
</tr>
</tbody>
I want to get the product price in the data cells(and maybe to make some operations with it later on the backend).
Is it possible by making a html module, or i need to put my code directly on my .tpl page and use the controller?
EDIT: Given the feedback on my original answer, the updated response is below:
You can access the price by using $price but this will contain the currency so you can insert the code below on the tpl file before your table:
<?php
$pricenew = $product['price'];
$pricenew = preg_replace( '/\D/', '', $pricenew );
?>
Now you can use $pricenew on your table as your formula requires it.
Original Answer:
Assuming you're creating an extension for the OpenCart install, you will need to have both a controller and a view (.tpl file) at the very least, best practises would encourage you to include a language file to make translation simpler. You may not require a model if you're just displaying certain products.
I would suggest reading this from the OpenCart documentation, there are also tutorials that make learning OpenCart extension development simpler. Here's a tutorial on making an extension that displays recent products.
I have made a custom module for odoo 8 that adds a photogallery on the website. The user can then add images and descriptions from the backend that will be automatically displayed in the frontend.
Is there a way to translate texts efficiently in odoo that is added "dynamically" by the user such as image descriptions or product descriptions?
My idea is that the visitor can change language in the frontend and the correct translation should then be displayed next to the image.
Or do I need to have a description field in the backend for each language that I want support for?
EDIT:
The gallery is implementedd like this at the moment
<t t-foreach="photos" t-as="photo">
<table style="width:90%" align="center">
<tr>
<td style="width:60%;"> <span t-field="photo.image" t-field-options='{"widget": "image"}' /> </td>
<td style="width:40%; vertical-align:top;" >
<font size="4" face="Comic Sans MS">
<u><t t-esc="photo.name"/></u><br></br>
<t t-esc="photo.description" />
</font>
</td>
</tr>
</table>
</t>
Is there a way to translate the content of the photo.description field and not just only the name?
It should be enough to make the description fields translatable in the backend. Just add translate=True to the field definitions. I don't know how you've added the gallery, but if it was done correctly, multi language support should work with users that are logged in! All other website users (without login) should see the website in default language.
I'm trying to use the dynamic HTML feature of Sideview to inject search results into my custom HTML. The problem is, any time I put a "Search" module into a dashboard the page hangs, and displays "Loading..." in the upper-right corner of the page. This happens even with an empty Search module. For instance, here is the page I'm trying to create.
XML:
<module name="Search" layoutPanel="panel_row1_col1" autoRun="True">
<param name="search"> | savedsearch last_command_by_engine</param>
<module name="HTML">
<param name="loadingText">Searching...</param>
<param name="src">last_commands_table.html</param>
</module>
</module>
last_commands _table.html:
<h1>Results: $results[0]$</h1>
<h1>Search: $search$</h1>
<table>
<thead>
<th>0</th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5</th>
<th>6</th>
</thead>
<tbody>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tbody>
</table>
The HTML template is rendered but the search is not carried out. There's just the "Loading..." message at the top and nothing else happens.
I would move this question to "SplunkBase", if you are still having issues as that is the official Splunk forum. You can then tag the question with sideview related tags, and i'm sure the user "#sideview" would pick it up quite quickly.. He is usually very active on the forum and very helpful.
Not a direct answer, but hope it helps.
You may already have the answer but it is simply to move the HTML module out of the search module. Nesting like that won't work.
Since I have installed the mvc4 RC, the razor autoresolve url that replaces ~ by the application root does not work in html 5 data-* attributes. ie:
In ASP.NET MVC4 beta :
<table id="userTable" class="dataTable" data-table-source="~/api/user/Users">
<tr>
<td data-field="OperatorCode">
#user.Code
</td>
<td>
edit
</td>
</table>
was transformed in
<table id="userTable" class="dataTable" data-table-source="/api/user/Users">
<tr>
<td data-field="OperatorCode">
operatorCode 1
</td>
<td>
edit
</td>
</table>
but in RC it is transformed in:
<table id="userTable" class="dataTable" data-table-source="~/api/user/Users">
<tr>
<td data-field="OperatorCode">
operatorCode 1
</td>
<td>
edit
</td>
</table>
As you can see in this version the ~ remains.
Is it by design ? If yes, is there any configuration parameter to change in order to reactivate the resolution in html5 data-* attribute? I have no found the explanation in the release notes.
Thank you.
This also happens in MVC4 final. It makes sense that this is by design to avoid cases where you don't want to have "~" resolved for certain data parameters.
Easy fix is to wrap them in #Url.Content again, not as nice but it works.
<html data-root="#Url.Content("~/")">
PS. I checked the MVC4 source code. There are no options to enable resolving of "data-" attributes. "data-" attributes are simply treated as literals.