change table pagesize dynamic in java struts - java

i use java struts framework. in list page, record is listed on table
<display:table class="table980" id="table1" name="sessionScope.ruhsatListe"
sort="list" pagesize="100" requestURI="/IletimAction.do?target=rListele"
export="true">
<display:column class="tableItem" property="sicilNo" title="Sicil No" sortable="true" headerClass="tableColHeadingSort" />
i want to change pagesize attr. listing 10 record or 50 record or 100
i used jquery but not working and code is:
function(deger){
location.reload();
$("#table1").removeAttr("pagesize");
$("#table1").attr('pagesize', deger);
}
what can i change pagesize as dynamic? i use jquery

When your jsp tag gets evaluated at the server, it gets converted to simple html tags and your attributes would probably disappear by the time it reaches the browser for rendering. So simply changing pageSize attribute at browser will not help.
What you need to do is a server hit, something like,
$.get('/IletimAction.do?target=rListeleTable', function (tableData) {
// Replace your entire table content with tableData
})
Needless to say /IletimAction.do?target=rListeleTable (Note the difference in URL with yours) should return your updated <display:table/> jsp content.
This is only one way of doing this, there might be better ways, if you can check Struts Ajax documentation.

Related

data-format version in orbeon view

I'm trying to create a form in orbeon forms with a repeated section, but Orbeon generates extra tags around my xml and then gets confused.
I've posted about this problem before:
Orbeon forms generates duplicate tags
The method described in the answer works great, and makes it possible to save the data to the database with data-format-version=edge. The view in the review page is also correct. I just can't seem to find out how to use this in the 'view' or 'edit' pages, I've tried passing the request parameter data-format-version=edge, both through the embedding api and in the URL of none-embedded orbeon but it does not seem to work.
Any ideas?
Edit:
When viewing a form ( http://localhost:8080/orbeon/fr/test/test/view/6fcd81f2612019deab5bb9f4031a92bc1b2b62ec) with the following xml in the database (xml column of orbeon_form_data):
<form>
<section-1>
<control-1/>
<mygrid>
<mygrid-iteration>
<control-5>vijf</control-5>
<control-6>zes</control-6>
</mygrid-iteration>
<mygrid-iteration>
<control-5/>
<control-6/>
</mygrid-iteration>
</mygrid>
</section-1>
The repeated sections are not shown correctly. When I edit the form (http://localhost:8080/orbeon/fr/test/test/edit/6fcd81f2612019deab5bb9f4031a92bc1b2b62ec). I can see in the form inspector that the xml has changed:
<form>
<section-1>
<control-1/>
<mygrid>
<mygrid-iteration>
<mygrid-iteration>
<control-5>vijf</control-5>
<control-6>zes</control-6>
</mygrid-iteration>
<mygrid-iteration>
<control-5/>
<control-6/>
</mygrid-iteration>
</mygrid-iteration>
</mygrid>
</section-1>
</form>
Notice the extra 'mygrid-iteration' tag. I've tried localhost:8080/orbeon/fr/test/test/edit/6fcd81f2612019deab5bb9f4031a92bc1b2b62ec?data-format-version=edge and many variations, but it doesn't seem to make any difference.

Display different images from an action in a JSP

I have a jsp page which iterates a list of users. Each user has his own display picture. I want to display these display pictures.
The problem is that when the page is loaded all the images are the same instead of a different image for each user.
The image tag in the iterator is this :
<img src="<s:url action="getUserImage">
<s:param name="user">
<s:property value="userId"/>
</s:param>
</s:url>"/>
and the action looks like this
this.inputStream = ByteArrayInputStream(userService.getUserById(Integer.parseInt(user)).getDisplayPicture());
While debugging I discovered that when executing the action for each image, the 'user' property is always the same.
The funny thing is that when I inspect the imgs elemnt on a browser, the src parameters are all correct (meaning each of them has its own different values).
I'm using spring framework, auto wiring action classes ..
struts.objectFactory value ="spring"
Shouldn't userService.getUserById(Integer.parseInt(user) be userService.getUserById(Integer.parseInt(userId) ?
#Component
#Scope("prototype")
did the trick !
action class was reusing the same id for each request

Displaytag sort my table but only on first page

I use a display table on a formBean :
<display:table name="${TableReferentielleFormBean.listeTableReferentielle}"
id="listeTableReferentielle" pagesize="${nb}" width="100%" class="table-separateur"
requestURI="${requestURI}" >
When I click on a column header on a paginated table, my result is a well sorted list in the table on first page. but the sort is lost when I click on another page of my table. Is there a configuration for display tag in order to keep this sorting criteria? Everything is managed by display tag with its request parameters (d-xxx-s etc.) and nothing in my servlet (requestURI value).
I 've already the displaytag.properties customized with the sort.amount = list value and I'm sure that this properties file is taken into account (I change another property to test it).
Try setting sort="list" right in your display:table declaration.

In JSP, what do the path and value attribute do within the input tag, and how does the form prefix affect them?

Just wanted a clear answer for a direct question -- google results have been all over the place or don't address the combos you'll see below.
I'm generally a JSP newbie and have been screwing around with the following code.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
cssClass="contentTextInput" cssStyle="width: 229px" />
When I put that into my JSP page and load my website, it works fine and looks as my cssClass defines it. Then I start messing with it because I want it to display a default value.
<form:input id="theId" path="path.copied.directly.fromSomewhereElse"
value="blah" cssClass="contentTextInput" cssStyle="width: 229px" />
Suddenly, HTTP 500, an org.apache.jasper.JasperException! So I decide to remove the path altogether, while leaving in the value. This is just step 1 in something I know works because of prior experience. The code is now:
<form:input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
That actually throws an exception, too -- but then I remove the form prefix and it works-- mostly. You see, the cssClass's effects are now gone; it looks like a regular, unaffected input textbox. Here's the code so far.
<input id="theId" value="someClass.valueIWantAsDefault"
cssClass="contentTextInput" cssStyle="width: 229px" />
What exactly do these attributes (and prefix) do that makes this mix-and-match work?
I'm guessing you're dealing with a jsp page that relies on a JSP custom tag library that's part of the Spring Framework. Here are the docs for the <form:input> tag. value is not a valid attribute for this custom tag as you can see in the docs link I provided above. When you remove the form:, you're turning the tag into a plain old HTML <input> tag which is why your error is going away at that point. It's also why your css stops working. cssClass is not the correct attribute for the HTML <input> tag. It's simply class. They called it cssClass in the jsp custom tag lib most likely to avoid a lower level collision with the Object.getClass() method (long story, just take my word for it).

Write Multiple Full HTML 'Files' to Single Output Stream?

I'm writing a testing utility- I want to show multiple finished HTML "pages" in a single browser window.
Is this possible? I'm using Java Servlets.
For example, normally the user goes to a utility screen, fills in a bunch of fields and POSTS this to my servlet, which builds up a full HTML stream based on their input and writes it to HttpServletResponse.getWriter(). When the user views source, they get a <html> ... </html>.
What I want to do is allow users to request multiple "screens" and get the results in a single web page where you'd scroll down to see the 2nd, 3rd, etc. screens, maybe there is some kind of divider in between. I thought of frames or iframes, but didn't have luck. I have seen where I can write my big html stream to a javascript variable, then use document.write to dump it into the iframe. But that seems pretty awkward, and I'd have to be really careful about escaping quotes and stuff.
You will have to use iframes or frames to do this. A single web page can only contain one set of html tags and thus one html page.
Another idea would be to render the page by your script and then capture a picture of it and then have a page containing images. You will of course loose all interaction with the page.
I'm not sure what you're trying with your frames, but I imagine frames should work OK for what you've described.
Instead of trying to post to more than one URL from your form, you just post to a servlet that returns a page with the frameset, and each frame has a source that points to one of the URLs you want to test. For example:
<form action="testServlet" method="post">
<input type="text" name="someValue" />
</form>
The testServlet then returns a page with this content:
<frameset rows="33%,33%,33%">
<frame src="testUrl1?someValue=value">
<frame src="testUrl2?someValue=value">
<frame src="testUrl3?someValue=value">
</frameset>
The only problem with this is that you're doing a GET instead of a POST, but that's easy to get around. All you would need do is to implement the doGet method within your servlets and just call doPost from within doGet.
Just leave out the <html>/</html> tags for each page and wrap the whole thing inside a single large ....
Like this maybe:
<html>
[page1Content]
<hr />
[page2Content]
<hr />
[page3Content]
<hr />
</html>

Categories

Resources